2011-01-23 62 views

回答

6

哥們我可以解釋爲醉......但在CAlayers

NO的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:,這是肯定的。)