Skip to content

LayerView

fumoboy007 edited this page Nov 27, 2020 · 2 revisions

LayerView

A layer-backed view with additional APIs for setting background color, border width, border color, and corner radius.

open class LayerView: NSView

Use if you do not need to do custom drawing.

Supports animations.

Inheritance

NSView

Initializers

init(frame:)

public override init(frame frameRect: NSRect)

init?(coder:)

public required init?(coder: NSCoder)

Properties

backgroundColor

The background color of the view.

var backgroundColor = NSColor.clear

The default value is no color.

Animatable.

borderWidth

The width of the border around the view.

var borderWidth: BorderWidth

The default value is 0.

To animate, use animatableBorderWidthInPoints or animatableBorderWidthInPixels.

animatableBorderWidthInPoints

An animatable version of the borderWidth property. Values are in points.

var animatableBorderWidthInPoints: CGFloat = 0

The fromValue of the animation will be automatically set to the current value of borderWidth.

animatableBorderWidthInPixels

An animatable version of the borderWidth property. Values are in pixels.

var animatableBorderWidthInPixels: CGFloat = 0

The fromValue of the animation will be automatically set to the current value of borderWidth.

borderColor

The color of the border around the view.

var borderColor = NSColor.black

The default value is opaque black.

Animatable.

cornerRadius

The radius of the rounded corners of the view.

var cornerRadius: CGFloat = 0

The default value is 0.

Animatable.

wantsUpdateLayer

var wantsUpdateLayer: Bool

Methods

encode(with:)

open override func encode(with aCoder: NSCoder)

updateLayer()

open override func updateLayer()

viewDidChangeBackingProperties()

open override func viewDidChangeBackingProperties()

defaultAnimation(forKey:)

open override class func defaultAnimation(forKey key: NSAnimatablePropertyKey) -> Any?

animation(forKey:)

open override func animation(forKey key: NSAnimatablePropertyKey) -> Any?