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. Use if you do not need to do custom drawing. Supports animations.

open class LayerView: NSView

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. Corresponds to the backgroundColor property of CALayer. Animatable.

var backgroundColor = NSColor.clear

The default value is no color.

borderWidth

The width of the border around the view. Corresponds to the borderWidth property of CALayer.

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. Corresponds to the borderColor property of CALayer. Animatable.

var borderColor = NSColor.black

The default value is opaque black.

cornerRadius

The radius of the rounded corners of the view. Corresponds to the cornerRadius property of CALayer. Animatable.

var cornerRadius: CGFloat = 0

The default value is 0.

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?
Clone this wiki locally