How to add a CALayer to an NSView on Mac OS X

前端 未结 4 369
灰色年华
灰色年华 2021-02-02 12:37

I\'m trying to learn how to use and implement CALayer in a Mac Objective-C application, but I can\'t seem to probably do the most basic thing - add a new layer and

4条回答
  •  旧巷少年郎
    2021-02-02 13:10

    Put this out of the drawRect. I normally put my layer setup in either the init method or the viewDidLoad.

    Otherwise anytime the view is drawn a new layer is added and allocated. Also I've never used the [layer display] line before. The docs actually tell you not to call this method directly.

提交回复
热议问题