问题描述
这些方法中的哪一种(如果有)将是适合的位置:
Which, if either, of these methods would be an appropriate place to:
- 更改CATextLayer的文本
- 将其他图像加载到CAImageLayer
- 告诉子层自己更新
推荐答案
伙计,我可能很醉……但是CAlayers
Dude I may be way drunk ... but there is NO drawRect method in CAlayers
我认为您可以使用drawInContext:
来(吸引)到CALayers,但是自第二次世界大战以来,没有人足够做到这一点.
I think you can use drawInContext:
to actually (gulp) draw in to CALayers, but nobody is man enough to do that since WW2.
关于显示,您无需调用它,它基本上会更新您使用.contents
设置的内容.
Regarding display, you don't need to call it, it basically updates what you set using .contents
.
我只是用.contents
这样的东西...
I just use .contents
something like this ...
[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:
...
Say one had the guts to write one's own drawInContext:
...
在这种情况下,当您调用displayAsNeeded
时,它会被调用(或抽象出来...或重新计算,等等). (我没必要打displayAsNeeded:
,这是肯定的.)
In that case, it gets called (or abstracted out ... or recalculated, or something) when you call displayAsNeeded
. (I've never needed to call displayAsNeeded:
, that's for sure.)
这篇关于究竟在CALayer的display/drawRect方法中会发生什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!