你能告诉我为什么这段代码没有显示图片吗?为什么CALayer不显示图像?
CALayer *layerBack = [CALayer layer];
addedObject = [[UIImage alloc]initWithContentsOfFile:[[NSBundle mainBundle]
pathForResource:[NSString stringWithFormat: @"%@%d", PREFIX, number] ofType:@"png"]];
layerBack.bounds=CGRectMake(0.0f,0.0f,selectedImage.size.height,selectedImage.size.width);
layerBack.position=CGPointMake(200,200);
layerBack.contents = (id)selectedImage.CGImage;
// in theory I think this line should be equal to selectedImage.CGImage, but when I do that, Xcode shows me an error!
[self.view.layer addSublayer:layerBack];
[layerBack display];
这石英的东西让我疯狂!请帮忙!
是的,图像在那里,正在工作,但我看到这个代码后是一个空白的屏幕。
你为什么不只是使用的意见,特别是和的UIImageView它的imageNamed方法,从而降低这个代码大约三线? – mahboudz 2009-09-10 18:33:00
,因为我必须在最后将最终结果转移到文件中,并且最后难以将转换从UIView复制到CGLayers。 – SpaceDog 2009-09-10 22:34:55