How to draw inner shadow text on Cocoa for Mac OS X

How to make an inner shadow for text in Cocoa for Mac OS X?

I am subclassing NSView to create a record control with a gradient background and internal text shaded over it.

All current Core Graphics answers on stackoverflow seem to explain drawing text shadows on Cocoa Touch.

+4
source share
1 answer

You may think too hard. If I understand your problem correctly, the only thing you really want to do is set the text style. Then do it simply using:

[[object cell] setBackgroundStyle:NSBackgroundStyleRaised]; 

where object is an instance of the NSTextField class.

This is all for you. Then your gradient background can be achieved, for example, with a custom view using NSGradient. See here

Advantage: you have the proper instance of NSTextField without having to subclass it or do other unnecessary things, such as implementing everything that NSTextField does on its own in the NSView subclass.

+4
source

Source: https://habr.com/ru/post/1389574/


All Articles