关于ios动画
来源:互联网 发布:ppt数据分析图表制作 编辑:程序博客网 时间:2024/05/29 17:54
动画分为两种UIView层动画 CALayer层动画。
UIView层动画分为两种类型:
1.属性动画
2.过渡动画
属性动画之block
[UIView animateWithDuration:1 animations:^{ self.AView.alpha = 0.3; }]; [UIView animateWithDuration:3 animations:^{ self.AView.transform = CGAffineTransformMakeRotation(M_PI_4); self.AView.backgroundColor = [UIColor grayColor]; self.AView.bounds = CGRectMake(0, 0, 100, 100); } completion:^(BOOL finished) { NSLog(@"结束"); }];
[UIView animateWithDuration:2 delay:2 options:UIViewAnimationOptionAllowUserInteraction animations:^{ self.AView.transform = CGAffineTransformMakeRotation(M_PI_4); self.AView.backgroundColor = [UIColor grayColor]; self.AView.bounds = CGRectMake(0, 0, 100, 100); } completion:^(BOOL finished) { self.AView.backgroundColor = [UIColor redColor]; }];
[UIView animateWithDuration:2 delay:2 usingSpringWithDamping:0.1 initialSpringVelocity:2 options:UIViewAnimationOptionAllowUserInteraction animations:^{ self.AView.transform = CGAffineTransformMakeRotation(M_PI_4); self.AView.backgroundColor = [UIColor grayColor]; self.AView.bounds = CGRectMake(0, 0, 100, 100); } completion:^(BOOL finished) { }];
过渡动画之 普通翻页效果
UIView *containerView =self.view.superview; [UIViewtransitionWithView:containerView duration:2options:UIViewAnimationOptionTransitionCurlUpanimations:^{ [self.viewremoveFromSuperview] ; [containerView addSubview:XVC.view]; } completion:^(BOOL finished) { }];
CALayer层动画
CAlayer层在做属性动画时并不是所有的属性都可以做动画 只有属性后面带Animatable的才可以做动画。
CABasicAnimation *basicAnimation = [CABasicAnimationanimationWithKeyPath:@"backgroundColor"]; basicAnimation.duration =2; basicAnimation.fromValue = (__bridgeid)([UIColoryellowColor].CGColor); basicAnimation.toValue = (__bridgeid)([UIColorredColor].CGColor); [self.AView.layeraddAnimation:basicAnimation forKey:@"BS"];
类似于QQ的弹框的抖动效果
CAKeyframeAnimation *keyFrameAnimation = [CAKeyframeAnimationanimationWithKeyPath:@"position.x"]; CGFloat x =self.AView.center.x; CGFloat leftX = x -10; CGFloat rightX = x +10; NSNumber *X = [NSNumbernumberWithFloat:x]; NSNumber *leftx = [NSNumbernumberWithFloat:leftX]; NSNumber *righty = [NSNumbernumberWithFloat:rightX]; NSArray *values =@[X,leftx,X,righty,X,leftx,X,righty,X]; keyFrameAnimation.values = values; [self.AView.layeraddAnimation:keyFrameAnimation forKey:@"keyFrame"];
CATransition 转场动画具有方块翻页效果
CATransition *catransition = [CATransitionanimation]; // 1获取self.view.superView UIView *view =self.view.superview; catransition.type =@"cube"; catransition.duration =3; catransition.startProgress =0.3; // 开始动画 catransition.endProgress =0.8; // 结束动画 // 2给self.view.superView添加动画 [view.layeraddAnimation:catransition forKey:@"catransition"]; // 3移除原来的View,添加新的View [self.viewremoveFromSuperview]; XViewController *XVC = [self.storyboardinstantiateViewControllerWithIdentifier:@"X"]; [view addSubview:XVC.view];
CAAnimationGroup可融合前面的动画 做出多动画效果
CAAnimationGroup *group = [CAAnimationGroupanimation]; CABasicAnimation *basicAnimation = [CABasicAnimationanimationWithKeyPath:@"backgroundColor"]; basicAnimation.duration =2; basicAnimation.fromValue = (__bridgeid)([UIColoryellowColor].CGColor); CAKeyframeAnimation *keyFrameAnimation = [CAKeyframeAnimationanimationWithKeyPath:@"position.x"]; CGFloat x =self.AView.center.x; CGFloat leftX = x -10; CGFloat rightX = x +10; NSNumber *X = [NSNumbernumberWithFloat:x]; NSNumber *leftx = [NSNumbernumberWithFloat:leftX]; NSNumber *righty = [NSNumbernumberWithFloat:rightX]; NSArray *values =@[X ,leftx,X,righty,X,leftx,X,righty,X]; keyFrameAnimation.values = values; group.duration =2; group.animations =@[basicAnimation,keyFrameAnimation]; [self.AView.layeraddAnimation:group forKey:@"group"];
阅读全文
1 0
- 关于IOS动画
- 关于 iOS 基础动画
- 关于ios帧动画
- 关于ios动画
- iOS关于核心动画CoreAnimation
- iOS关于Animation 动画效果
- 关于 iOS自定义转场动画
- iOS中关于动画效果的要点
- iOS中关于动画效果的要点
- iOS 关于MBProgressHUD的使用 自定义动画
- 关于ios 用Instrument优化动画性能
- 关于IOS中通过图片实现动画效果
- iOS关于启动动画Default.png的设置
- iOS开发 - 关于启动页动画的杂谈
- iOS 关于自定义转场动画,以UITabBarController为例
- 关于rotate动画在ios设备无效的问题
- iOS动画 核心动画
- iOS动画 UIView动画
- rownum用法详解
- Java泛型详解(上)
- 除黑头妙招大全
- java要注意的地方(查缺补漏)
- 队列同步器
- 关于ios动画
- 小心不可见字符组成的不可见字符串
- MySQL中的DDL、DML、DCL、DQL
- 分享一个交叉编译qt库的教程
- HYSBZ 2301 Promblem b 莫比乌斯反演+分块
- 阅读笔记 > 编程需要考虑的问题
- 关于文件
- passwd命令
- 深究js(二)——类型