0

Simple question, but I can't find any answers... How I can change corner radius of NSCollectionViewItem instance?

Artem Novichkov
  • 2,356
  • 2
  • 24
  • 34

1 Answers1

1

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
    }
}
Artem Novichkov
  • 2,356
  • 2
  • 24
  • 34