iphone中CABasicAnimation和UIView动画的区别[转]
关于UIView动画:
- [UIView beginAnimations:@"zoom out" context:nil];
- [UIView setAnimationDuration:1.f];
- [UIView setAnimationCurve:UIViewAnimationCurveEaseOut];
- cover.transform = CGAffineTransformMakeScale(9.25,7.05);
- cover.center = CGPointMake(430, 512);
- [UIView commitAnimations]
UIView动画是应用在一个view上面的。
关于CABasicAnimation动画:
- - (CAAnimation *)animationMove:(CGPoint)rootCenter
- {
- CABasicAnimation *animationMove
- = [CABasicAnimation animationWithKeyPath:@"position"];
- animationMove.duration = 1;
- animationMove.autoreverses = NO;
- // animationMove.delegate = self;
- animationMove.removedOnCompletion = NO;
- animationMove.fillMode = kCAFillModeForwards;
- animationMove.fromValue = [NSValue valueWithCGPoint:self.oldCoverCenter];
- animationMove.toValue =[NSValue valueWithCGPoint:rootCenter];
- return animationMove;
- }
CABasicAnimation动画是应用在一个layer上面的。
注:
1,把一个image放在一个view的layer上来放大的时候,如果用UIView来做,图片不会太多的失真和闪烁的效果,但是用CABasicAnimation来做失真和闪烁现象会很严重,效果很不好。
2,做 动画的叠加效果 很简单,只要把各自的动画放在一起就可以了。请看这个效果:一本书边移动到屏幕中间,边放大,边打开封面的效果。
- [imageLayer addAnimation:[self animationOpen] forKey:@"Open"];
- [UIView beginAnimations:@"zoom out" context:nil];
- [UIView setAnimationDuration:1.f];
- [UIView setAnimationCurve:UIViewAnimationCurveEaseOut];
- cover.transform = CGAffineTransformMakeScale(5.5,5.5);
- cover.center = CGPointMake(629, 384);
- [UIView commitAnimations];
- - (CAAnimation *)animationOpen
- {
- CABasicAnimation *animationOpen
- = [CABasicAnimation animationWithKeyPath:@"transform.rotation.y"];
- animationOpen.duration = 1;
- animationOpen.autoreverses = NO;
- animationOpen.delegate = self; //然后执行真正地打开书的内容
- animationOpen.removedOnCompletion = NO;
- animationOpen.fillMode = kCAFillModeForwards;
- animationOpen.fromValue = [NSNumber numberWithFloat:-M_PI/5];
- animationOpen.toValue = [NSNumber numberWithFloat:-M_PI/1.5];
- return animationOpen;
- }
分类:
ios
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 如何编写易于单元测试的代码
· 10年+ .NET Coder 心语,封装的思维:从隐藏、稳定开始理解其本质意义
· .NET Core 中如何实现缓存的预热?
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
· 10年+ .NET Coder 心语 ── 封装的思维:从隐藏、稳定开始理解其本质意义
· 地球OL攻略 —— 某应届生求职总结
· 提示词工程——AI应用必不可少的技术
· Open-Sora 2.0 重磅开源!
· 周边上新:园子的第一款马克杯温暖上架