How to interact with layer-backed views on the Mac

扶醉桌前 提交于 2019-12-05 16:54:59

no layer backing needed IMHO:

for 1. I do a pattern image

NSImage *patternImage = [NSImage imageNamed:@"pattern"];
[window setBackgroungdColor:[NSColor colorWithPatternImage:patternImage]];

for 2. add an NSImageView as a subview of the contentview

NSImageView *v = ...
[[window contentView] addSubview:v]; 

on mac some views dont respond nicely IF layer backed :: e.g. pdfview

Make a superview container A. Add a subview B to A for all your NSView needs (buttons, etc.). Add a subview C to A for all your Core Animation needs.

Edit: Even better: use superview A for all your NSView needs and one subview C for your Core Animation needs, ignoring view B altogether.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!