How do I use CALayer with the iPhone?

后端 未结 3 1651
余生分开走
余生分开走 2021-02-10 18:05

Currently, I have a UIView subclass that \"stamps\" a single 2px by 2px CGLayerRef across the screen, up to 160 x 240 times.

I currently animate this by moving the UIVie

3条回答
  •  太阳男子
    2021-02-10 18:09

    Okay, well, if you want something that has some good examples of CA good that draws things like that and works on the phone, I recommend the GeekGameBoard code that Jens Aflke published (it is an improved version of some Apple demo code).

    Based on what you are describing I think you are doing somthing way more complicated than it needs be. My impression is you want basically a static view that you are animating by shifting its position so that it is partially off screen. If you just need to set some static content in your drawRect going through layers is not going to be faster than just calling CGFillRect() with your color. After that you could just use implicit animations and the animator proxy on UIView to move the view. I suspect you could even get rid of the custom drawRect: implementation with a patterned UIColor, but I honestly have not benchmarked the difference between the two.

提交回复
热议问题