Add shadow (recessed text effect) to Cocoa label without degrading text rendering quality

后端 未结 2 779
无人共我
无人共我 2021-02-01 07:57

I\'d like to create statusbar with text effect like in Safari or iTunes, i.e. recessed text.

\"example\"

However,

相关标签:
2条回答
  • 2021-02-01 08:47

    There is a built-in way to do this:

    [[yourTextField cell] setBackgroundStyle:NSBackgroundStyleRaised];
    
    0 讨论(0)
  • 2021-02-01 08:48

    It's a cheap old trick: You draw the text in white at an offset and then draw the black text on top of it.

    There is a hook for shadows in the text-drawing system, NSAttributedString's NSShadowAttributeName. But testing this out, it appears to kill the subpixel antialiasing as well.

    0 讨论(0)
提交回复
热议问题