Creating a label using NSTextField is blurry

后端 未结 8 1164
后悔当初
后悔当初 2021-01-06 03:05

I\'m trying to create a label programmatically using NSTextField, but it comes out blurry: screenshot

This is my code so far:

NSTextfield *textfield          


        
相关标签:
8条回答
  • 2021-01-06 03:35

    If you have no background (including clear) and your text is a subview of any layer-backed superview (you've turned on "wants layer" in code or in IB to allow animations/transitions), you'll get blurry text. You have to choose either no layer backed view or a label with a solid background color.

    0 讨论(0)
  • 2021-01-06 03:37

    Try this below:

    textField.drawsBackground = true
    textField.backgroundColor = NSColor.white.withAlphaComponent(.leastNormalMagnitude)
    
    0 讨论(0)
提交回复
热议问题