iOS动画积累

2017.3.8
    [CATransaction begin];
    [CATransaction setDisableActions:NO];
    [CATransaction setAnimationTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]];
    [CATransaction setAnimationDuration:3];
    [_animationLayer setFrame:CGRectMake(20, 60, 300, 6)];
    [CATransaction commit];
2017.3.9
  • CABasicAnimation+CALayer实现缩放动画
缩放.gif
    CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:@"transform.scale"];
    animation.fromValue = @(0.1);
    animation.toValue = @(1);
    animation.duration = 2;
    [_scaleLabel.layer addAnimation:animation forKey:nil];
  • CAKeyframeAnimation+CALayer实现抖动动画
    关键帧
抖动.gif
    CAKeyframeAnimation *animation = [CAKeyframeAnimation animationWithKeyPath:@"transform"];
    animation.duration = 0.5;
    
    NSMutableArray *values = [NSMutableArray array];
    [values addObject:[NSValue valueWithCATransform3D:CATransform3DMakeScale(0.1, 0.1, 1.0)]];
    [values addObject:[NSValue valueWithCATransform3D:CATransform3DMakeScale(1.2, 1.2, 1.0)]];
    [values addObject:[NSValue valueWithCATransform3D:CATransform3DMakeScale(0.9, 0.9, 1.0)]];
    [values addObject:[NSValue valueWithCATransform3D:CATransform3DMakeScale(1.0, 1.0, 1.0)]];
    
    animation.values = values;
    [_keyframeView.layer addAnimation:animation forKey:nil];

无量何质

2017.3.13
  • options:UIViewAnimationOptionRepeat实现重复动画
    仿扫码框动画
    重复动画.gif
[UIView animateWithDuration:1.5f delay:0 options:UIViewAnimationOptionRepeat animations:^{
        CGRect rect = _saomatiao.frame;
        rect.origin.y = 90;
        [_saomatiao setFrame:rect];
    } completion:^(BOOL finished) {
        CGRect rect = _saomatiao.frame;
        rect.origin.y = 60;
        [_saomatiao setFrame:rect];
    }];
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • 在iOS中随处都可以看到绚丽的动画效果,实现这些动画的过程并不复杂,今天将带大家一窥ios动画全貌。在这里你可以看...
    每天刷两次牙阅读 8,551评论 6 30
  • 在iOS实际开发中常用的动画无非是以下四种:UIView动画,核心动画,帧动画,自定义转场动画。 1.UIView...
    请叫我周小帅阅读 3,142评论 1 23
  • 显式动画 显式动画,它能够对一些属性做指定的自定义动画,或者创建非线性动画,比如沿着任意一条曲线移动。 属性动画 ...
    清风沐沐阅读 1,971评论 1 5
  • 在iOS中随处都可以看到绚丽的动画效果,实现这些动画的过程并不复杂,今天将带大家一窥iOS动画全貌。在这里你可以看...
    F麦子阅读 5,141评论 5 13
  • 先看看CAAnimation动画的继承结构 CAAnimation{ CAPropertyAnimation { ...
    时间不会倒着走阅读 1,683评论 0 1