美文网首页
iOS动画积累

iOS动画积累

作者: 怪客半 | 来源:发表于2017-10-25 11:06 被阅读5次
    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动画积累

          本文链接:https://www.haomeiwen.com/subject/gfwbgttx.html