Tuesday, November 23, 2010

iPhone dev Stupidity 134: Core Animation doc reading

* CALayer must be hosted with UIView. UIView provides the event-handling for underlying layers, while the layers provide display of the content.
  - for iPhone UIView.layer
  - for Mac OS, you need to enable it: theView.wantsLayer = YES

* Sublayers do not clip to parent by default (UIView does). To enable, theLayer.masksToBounds = YES

* To position content image in a CALayer:
  - kCAGravityResize
  - kCAGravityResizeAspect
  - kCAGravityResizeAspectFill

  will do a much better job than write your own resize & fill code

* You can stop an animation by: removeAnimationForKey:

* AffineTransform类描述了一种二维仿射变换的功能,它是一种二维坐标到二维坐标之间的线性变换,保持二维图形的“平直性”(译注: straightness,即变换后直线还是直线不会打弯,圆弧还是圆弧)和“平行性”(译注:parallelness,其实是指保二维图形间的相对位置关系不变,平行线还是平行线,相交直线的交角不变。)。仿射变换可以通过一系列的原子变换的复合来实现,包括:平移(Translation)、缩放(Scale)、翻转(Flip)、旋转(Rotation)和错切(Shear)。

* When an instance of CAAnimation receives the runActionForKey:object:arguments: message it responds by adding itself to the layer’s animations, causing the animation to run:

- (void)runActionForKey:(NSString *)key 

                 object:(id)anObject 

              arguments:(NSDictionary *)dict 

{ 

     [(CALayer *)anObject addAnimation:self forKey:key]; 

} 




No comments: