0

Windows API has very powerful functions that allow to draw native controls in all states:

DrawThemeBackground() DrawThemeText()

Here's a really nice example of their usage:

Windows Visual Themes: Gallery of Parts and States?

Does Cocoa have something similar?

rmaddy
  • 314,917
  • 42
  • 532
  • 579
Alex
  • 34,581
  • 26
  • 91
  • 135

1 Answers1

1

Apple has "soft deprecated" NSCell and the various control-specific subclasses, but you can use them for this. You create one, configure its properties, and then tell it to draw in a frame in a view.

Getting the properties just right can be tedious. You might want to create a control of the relevant kind in a test project's view (using IB) and then interrogate its cell's properties programmatically. And/or configure such a control to use a custom subclass of the corresponding cell class which logs which methods are called on it with what parameters in various scenarios.

Ken Thomases
  • 88,520
  • 7
  • 116
  • 154
  • Thanks for a detailed response. I'm very intrigued by the ability to log which methods are called with what parameters. Do you have a link where I can read about this? I don't have much Cocoa experience. Thanks! – Alex Apr 28 '19 at 10:30
  • Sorry, I don't have any particular link. I was just suggesting that you override any method about which you want to learn more and log the parameters before calling through to `super`. – Ken Thomases Apr 28 '19 at 20:29