Mac Developer Library

Developer

AppKit Framework Reference NSAppearance Class Reference

Options
Deployment Target:

On This Page
Language:

NSAppearance

Inheritance


Conforms To


Import Statement


Swift

import AppKit

Objective-C

@import AppKit;

Availability


Available in OS X v10.9 and later.

An NSAppearance object represents a file that specifies a standard or custom 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.

Typically, you customize a window by using Xcode to create an appearance file that contains the views you want to customize and the custom art that should be applied to them. Xcode transforms the file’s art content into a runtime format that AppKit can draw when the specified views are displayed.

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 appearance file 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 name of the appearance file to search for, without any path information.

    bundle

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

    Return Value

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

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.9 and later.

  • Returns the NSAppearance object with the specified name.

    Declaration

    Swift

    init?(named name: String) -> NSAppearance

    Objective-C

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

    Parameters

    name

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

    Return Value

    A standard or custom appearance object.

    Discussion

    When you specify a standard appearance name—such as NSAppearanceNameAqua—this method returns a built-in appearance. If you specify a custom appearance name, this method searches the main bundle for an appearance file that has the specified name.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    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.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    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.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    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

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    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.