NSView の背景色を直接指定できるようにする IBInspectable
import Cocoa
extension NSView {
@IBInspectable var backgroundColor: NSColor? {
get {
guard let layer = layer, let backgroundColor = layer.backgroundColor else {return nil}
return NSColor(cgColor: backgroundColor)
}
set {
wantsLayer = true
layer?.backgroundColor = newValue?.cgColor
}
}
}
Background Color 項目が属性インスペクターに現れる。
Author And Source
この問題について(NSView の背景色を直接指定できるようにする IBInspectable), 我々は、より多くの情報をここで見つけました https://qiita.com/usagimaru/items/2fbe2800886b7bba8b40著者帰属:元の著者の情報は、元のURLに含まれています。著作権は原作者に属する。
Content is automatically searched and collected through network algorithms . If there is a violation . Please contact us . We will adjust (correct author information ,or delete content ) as soon as possible .