关键字
1.Core Animation的核心类是CALayer,通过对其属性进行配置可以展现不同的外观,这些属性包括位置,尺寸,图片内容,背景色,边界,阴影,以及角半径。
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
![](https://images.cnblogs.com/OutliningIndicators/ExpandedBlockStart.gif)
CATextLayer *textLayer;textLayer = [CATextLayer layer];textLayer.anchorPoint = CGPointZero;//限定层的边界矩形的定位点,如在一个点normalized层坐标 - '(0,0)'是左下角边界矩形,'(1,1)'是右上角。默认为(0.5,0.5),即边界矩形的中心。textLayer.position = CGPointMake(10, 6);//该层的边界矩形的定位点对准在superlayer的位置。默认为零点textLayer.zPosition = 100;//在其superlayer层的位置的Z分量。默认为零textLayer.fontSize = 24;textLayer.foregroundColor = CGColorGetConstantColor(kCGColorWhite);
CALayer:图层也是按层级关系组织,不是响应链的一部分。
2.CAAnimation .控制图层属性产生的动画。
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
![](https://images.cnblogs.com/OutliningIndicators/ExpandedBlockStart.gif)
CABasicAnimation *posAnim = [CABasicAnimation animation]; posAnim.fromValue = [NSValue valueWithPoint:center];posAnim.duration = 1.5;posAnim.timingFunction = tf;CABasicAnimation *bdsAnim = [CABasicAnimation animation];bdsAnim.fromValue = [NSValue valueWithRect:NSZeroRect];bdsAnim.duration = 1.5;bdsAnim.timingFunction = tf;CALayer *layer = [CALayer layer];layer.contents = image;layer.actions = [NSDictionary dictionaryWithObjectsAndKeys:posAnim, @"position", bdsAnim, @"bounds", nil];
3.CATransaction用于多个动画的分组及同步,也可以临时禁用动画。
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
![](https://images.cnblogs.com/OutliningIndicators/ExpandedBlockStart.gif)
[CATransaction begin];[view.layer addSublayer:layer];layer.position = randomPoint;layer.bounds = NSRectToCGRect(imageBounds);[CATransaction commit];
2.联系
待续….
版权声明:本文为博主原创文章,未经博主允许不得转载。