Mac Developer Library

Developer

AppKit Framework Reference NSAppearance Class Reference

Options
Deployment Target:

On This Page
Language:

NSAppearance

An NSAppearance object represents a file that specifies a standard appearance that applies to a subset of UI elements in an app. An app can contain multiple appearance files and—because NSAppearance conforms to NSCoding—you can use Interface Builder to assign UI elements to an appearance.

If the art for a specific view can’t be found, AppKit searches for the art in the appearances of the view’s ancestors. A nil appearance means that a view uses the default Aqua appearance; a non-nil appearance means that the view uses an ancestor’s appearance.

When AppKit draws a control, it automatically sets the current appearance on the current thread to the control’s appearance. The current appearance can influence the actual drawing path and the return values you get when you access system fonts and colors. The current appearance also affects the appearance of text and images, such as the text and template images that can be displayed in a toolbar.

  • Creates an NSAppearance object initialized to the specified named appearance in the specified bundle.

    Declaration

    Swift

    init?(appearanceNamed name: String, bundle bundle: NSBundle?)

    Objective-C

    - (instancetype)initWithAppearanceNamed:(NSString *)name bundle:(NSBundle *)bundle

    Parameters

    name

    The named appearance to search for, without any path information.

    bundle

    The bundle in which to search for the named appearance. If bundle is nil, this method searches in the main bundle.

    Return Value

    An initialized appearance object, or nil if an error occurs.

    Availability

    Available in OS X v10.9 and later.

  • name name Property

    The name of the appearance. (read-only)

    Declaration

    Swift

    var name: String { get }

    Objective-C

    @property(readonly, copy) NSString *name

    Discussion

    See “Standard Appearances” for standard appearance names.

    Availability

    Available in OS X v10.9 and later.

  • Returns the NSAppearance object with the specified name.

    Declaration

    Swift

    init?(named name: String)

    Objective-C

    + (NSAppearance *)appearanceNamed:(NSString *)name

    Parameters

    name

    The name of a standard appearance. See “Standard Appearances” for standard appearance names.

    Return Value

    A standard appearance object.

    Discussion

    When you specify a standard appearance name—such as NSAppearanceNameAqua—this method returns a built-in appearance.

    Availability

    Available in OS X v10.9 and later.

  • Returns the NSAppearance object that’s set on the current thread.

    Declaration

    Swift

    class func currentAppearance() -> NSAppearance

    Objective-C

    + (NSAppearance *)currentAppearance

    Return Value

    The appearance object that’s set on the current thread.

    Discussion

    When a UI element draws on the screen, it automatically sets the appearance that it’s using on the current thread.

    Availability

    Available in OS X v10.9 and later.

  • Sets the current appearance to the specified NSAppearance object.

    Declaration

    Swift

    class func setCurrentAppearance(_ appearance: NSAppearance?)

    Objective-C

    + (void)setCurrentAppearance:(NSAppearance *)appearance

    Parameters

    appearance

    The NSAppearance object that should be used for the window or view, or nil to specify the default appearance.

    Discussion

    When you set an appearance on a window, all views in that window—including the window background and controls in both the frame and content areas—use that appearance. By default, AppKit sets the current appearance for standard windows and views during window drawing, so you don't need to use this method unless you want to change the current appearance of a specific window or view.

    You can use this method to set the current appearance for an offscreen view to the appearance that will be used when the view is drawn. To do this, use the offscreen view’s effectiveAppearance for the appearance parameter.

    Availability

    Available in OS X v10.9 and later.

  • Specifies whether the current appearance allows vibrancy.

    Declaration

    Swift

    var allowsVibrancy: Bool { get }

    Objective-C

    @property(readonly) BOOL allowsVibrancy

    Availability

    Available in OS X v10.10 and later.

  • These strings are used to specify standard appearances provided by OS X.

    Declaration

    Swift

    let NSAppearanceNameAqua: String let NSAppearanceNameLightContent: String let NSAppearanceNameVibrantDark: String let NSAppearanceNameVibrantLight: String

    Objective-C

    APPKIT_EXTERN NSString *const NSAppearanceNameAqua; APPKIT_EXTERN NSString *const NSAppearanceNameLightContent; APPKIT_EXTERN NSString *const NSAppearanceNameVibrantDark; APPKIT_EXTERN NSString *const NSAppearanceNameVibrantLight;

    Constants

    • NSAppearanceNameAqua

      NSAppearanceNameAqua

      The standard Aqua appearance.

      Available in OS X v10.9 and later.

    • NSAppearanceNameLightContent

      NSAppearanceNameLightContent

      The standard appearance that can be used by controls in light content areas (not including window-frame areas).

      In OS X v10.10 and later, light content should use the default Aqua appearance.

      Available in OS X v10.9 and later.

      Deprecated in OS X v10.10.

    • NSAppearanceNameVibrantDark

      NSAppearanceNameVibrantDark

      The vibrant appearance for dark content.

      This should only be set on an NSVisualEffectView or one of its subviews.

      Available in OS X v10.10 and later.

    • NSAppearanceNameVibrantLight

      NSAppearanceNameVibrantLight

      The vibrant appearance for light content.

      This should only be set on an NSVisualEffectView or one of its subviews.

      Available in OS X v10.10 and later.