How can I make an “appearance file” for NSAppearance?

后端 未结 2 1615
生来不讨喜
生来不讨喜 2020-12-24 08:02

I was reading the Cocoa documentation and stumbled across some new features in the 10.9 API.

From the docs I gather that the NSAppearance class and a re

2条回答
  •  生来不讨喜
    2020-12-24 08:33

    EDIT: Guilherme's response is more accurate, although there is still no public way of altering appearances like you can in iOS.

    NSAppearance isn't much like UIAppearance (from what I can tell), it only relates to having controls under normal or light colored appearances. An example of this would be when you draw into a popover (light) vs a window toolbar perhaps (normal), NSAppearance allows you to identify which environment you're drawing into. To be honest I haven't used it yet, but the most information I've found was in the WWDC 2013 video on What's new in Cocoa and the 10.9 release notes

    From my understanding, it allows you to specify what the control looks like on a particular background. If a control you use is to be reused on a different background, you could check the current appearance and draw your control accordingly using [NSAppearance currentAppearance]

    Another important part is that there is a new protocol your views or windows can adopt called the NSAppearanceCustomization protocol which allows you to specify that view's appearance. Not exactly sure how this works but it's there. Some Cocoa control also have these implemented which are discussed in the HIG for Controls.

    There are 2 appearances that Apple defines but you might be able to define your own using your own strings (again, not sure). At the bottom of the docs you linked to you'll find these 2 constants:

    APPKIT_EXTERN NSString *const NSAppearanceNameAqua;
    APPKIT_EXTERN NSString *const NSAppearanceNameLightContent;
    

    So it's no UIAppearance, it's just a way of knowing what type of background you're drawing onto.

提交回复
热议问题