0
当我为IKBrowserView设置背景时,根据视图大小调整背景大小:是否有将它设置为平铺图像的方法,重复但未调整大小?如何为CALayer设置平铺背景图像?
NSImage* backgroundImage = [NSImage imageNamed:@"wood-bg2.jpg"];
CALayer* aLayer = [CALayer layer];
//aLayer.contents = backgroundImage;
CIColor *ci = [[CIColor alloc] initWithColor:[NSColor colorWithPatternImage:backgroundImage]];
CGColorSpaceRef cs = [ci colorSpace];
const CGFloat *comps = [ci components];
CGColorRef cgColor = CGColorCreate(cs, comps);
aLayer.backgroundColor = cgColor;
[itemThumbnailImageBrowserView setBackgroundLayer:aLayer];
我试过了注释掉的代码和当前的代码,但都没有工作。 感谢
感谢,由于某种原因,colorWithPatternImage行给了我这样的警告:从兼容的指针类型 – aneuryzm 2013-02-12 12:40:31
传递参数1我不知道为什么,因为我经过NSImage中为你这是正确的内容类型 – aneuryzm 2013-02-12 12:40:47
啊,这是因为backgroundColor需要一个CGColor而不是一个NSColor – aneuryzm 2013-02-12 12:44:50