【发布时间】:2011-01-23 17:22:18
【问题描述】:
如果有的话,这些方法中的哪一个是合适的地方:
- 更改 CATextLayer 的文本
- 将不同的图像加载到 CAImageLayer 中
- 告诉子层进行自我更新
【问题讨论】:
标签: iphone macos ios drawing calayer
如果有的话,这些方法中的哪一个是合适的地方:
【问题讨论】:
标签: iphone macos ios drawing calayer
伙计,我可能喝醉了……但CAlayers 中没有 drawRect 方法
我认为您可以使用drawInContext: 来实际(吞下)吸引 CALayers,但自二战以来没有人有足够的能力这样做。
关于显示,你不需要调用它,它基本上会更新你使用.contents设置的内容。
我只是使用.contents 这样的东西...
[self.view setLayer:rearLayer];
[self.view setWantsLayer:YES];
rearLayer.frame = CGRectMake(gameBlah,gameBlah, 1024,768);
// note that we are dealing there with the mysteries of rearLayer positioning;
// it is measured by the SUPER layer of the layer in question!
// (indeed much as frame for the view is, if you think about it ..)
rearLayer.contents = (id)loadMacStylePng(@"spaceShip");
说有胆量自己写drawInContext: ...
在这种情况下,当您调用displayAsNeeded 时,它会被调用(或抽象出来......或重新计算,或其他)。 (我从来不需要打电话给displayAsNeeded:,这是肯定的。)
【讨论】: