Core animation 学习笔记
来源:互联网 发布:软件测试项目管理 编辑:程序博客网 时间:2024/05/22 13:06
图层
- 每一个UIView都有一个CALayer
- 改变UIView里Layer的frame,bounds,backgroundColor都会影响UIView
- 添加到父图层的子图层,当只设置bounds时.
- position为 {0,0}
- anchorPoint为{0.5,0.5} 子图层的中心位置
- CALayer *subLayer = [CALayerlayer];
subLayer.backgroundColor= [UIColoryellowColor].CGColor;
subLayer.bounds= CGRectMake(0,0,30,30);
subLayer.contents= (id)[UIImageimageNamed:@"snowman"].CGImage;
[self.redView.layeraddSublayer:subLayer];
PR(subLayer.bounds);
PP(subLayer.position);
PP(subLayer.anchorPoint); - 2015-09-09 22:10:18.571 Animation_practice[7328:472163] rect = {{0, 0}, {30, 30}}
2015-09-09 22:10:18.572 Animation_practice[7328:472163] point = {0, 0}
2015-09-09 22:10:18.572 Animation_practice[7328:472163] point = {0.5, 0.5}
- CALayer *subLayer = [CALayerlayer];
- anchorPoint可以当做一个拨动一个图层手柄,默认为它处于图层的中心位置{0.5,0.5},的改变anchorPoint会改变Layer在父图层上的坐标.
- 直接对layer的frame,bounds,position做赋值,会触发一个隐式动画,时长为默认的0.25秒.(root layer没有)
绘制
- CALayer可以通过delegate代理函数- (void)drawLayer:(CALayer *)
layer
inContext:(CGContextRef)ctx和重载
- (
void
)display来进行绘制内容
- 一般采用CGContextXXX函数集来进行绘制(由于不属于cocoa,所以在处理XXXCreateXXX函数时,需要手动释放内存CFRelease)
- 也可以通过赋值contents属性,来显示一张图片内容
动画
- 显示动画
- 它是由以下几个类来完成,如图
- 常用的有CAAnimationGroup,组合多个图层的动画
- CABasicAnimation,一般使用在位置,缩放,旋转
- CAKeyframeAnimation 一般针对一个图层关键帧操作,也就是一段时间连续多个不同的动作
- CATransition 主要做为隐式动页面转场动画,如淡入淡出,推入,翻滚,四个方向滑入,收缩,抽走
- UIView也提供了一些快捷的动画方式
- + (void)animateWithDuration:(NSTimeInterval)
duration
delay:(NSTimeInterval)delay
options:(UIViewAnimationOptions)options
animations:(void (^)(void))animations
completion:(void (^)(BOOL finished))completion
- + (void)animateWithDuration:(NSTimeInterval)
- 它是由以下几个类来完成,如图
0 0
- Core Animation学习笔记
- Core Animation学习笔记
- Core Animation学习笔记
- Core Animation学习笔记
- Core Animation学习笔记
- Core Animation 学习笔记
- core Animation学习笔记
- Core Animation学习笔记
- Core Animation 学习笔记
- Core Animation学习笔记
- Core Animation学习笔记
- Core Animation学习笔记
- Core Animation学习笔记
- Core Animation学习笔记
- Core animation 学习笔记
- Core Animation 学习笔记(二)
- Core Animation学习笔记三:CAkeyframeAnimation
- Core Animation学习笔记一:CATransactions
- 一个关于计算整数bit位上有多少个1的算法
- 文章标题
- 关键字匹配
- lnmp配置nginx
- 【译】VisionMobile:开发者经济报告2015 Q3(三):移动平台:剩下两个?
- Core animation 学习笔记
- 好的学习资源链接 ,持续更新....
- [MySQL FAQ]系列 — 为什么InnoDB表要建议用自增列做主键
- KSDKV1.2 学习
- bootstrap之表格篇--随记
- viewPager实现图片左右滑动
- PAT.1035-1045
- DirectShow下视频显示窗口设置
- Android开发之EditText属性详解