Reputation: 2341
Simple question, but I can't find any answers... How I can change corner radius of NSCollectionViewItem
instance?
Upvotes: 0
Views: 467
Reputation: 2341
view
of NSCollectionViewItem
doesn't have layer by default. You need to set wantsLayer
to true
, for example:
import Cocoa
class TestCellItem: NSCollectionViewItem {
override func viewDidLoad() {
super.viewDidLoad()
view.wantsLayer = true
view.layer?.backgroundColor = NSColor.red.cgColor
}
override func viewDidLayout() {
super.viewDidLayout()
view.layer?.cornerRadius = 20
}
}
Upvotes: 1