How to use CALayer with iPhone?

I currently have a subclass of UIView that "labels" one 2px by 2px CGLayerRef all over the screen, up to 160 x 240 times.

I am currently animating this by moving the UIView “up” to a 2 pixel screen (actually a UIImageView), and then draw the next “row”.

Will using multiple layers of CALayer speed up the rendering of this animation?

Are there any tutorials, sample applications, or code snippets for using CALayer with the iPhone SDK?

I ask that most of the code snippets I find show simple examples of using CALayer calls that do not work with the iPhone SDK. I appreciate any advice or pointers.

+4
source share
3 answers

Ok, ok, if you want something that has good CA examples that draw such things and work on the phone, I recommend GeekGameBoard , which Jens Aflke published (this is an improved version of some Apple demo code).

, , , , . , , , , , , . - drawRect, , , CGFillRect() . - UIView . , drawRect: UIColor, .

+4

CALayer , iPhone? , CoreImage, , . , , , , , ( - , UIView ), .

, , , . , , , , - UIView/CALayer/UIColor, , , , , .

, , , , , , , , .

- [UIColor initWithPatternImage:] , . , UIColor, .

+3

CALayer , iPhone?

grid . , CAConstraintLayoutManager CAConstraint QuartzCore.h.

, 20x20 CALayer UIView, .

UIView, drawRect. drawRect CGLayerRef s:

"off" 320x480.

"on" CGLayerRef 320x480 (), 320x2 ().

UIImageView 320x478 . "" .

, , CALayer :

  • , CALayer , ,
  • Make my animation smoother by letting me smoothly transition to the layer

Unfortunately, I cannot get the base CALayer to work at the moment and have not found a good piece of code to view and play.

+1
source

All Articles