2017.3.8
-
CATransaction+CAShapeLayer 实现直线动画
即改变矩形layer的frame
CATransaction:http://www.jianshu.com/p/c8ffa7ab50d1
layer直线动画.gif
[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实现缩放动画
CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:@"transform.scale"];
animation.fromValue = @(0.1);
animation.toValue = @(1);
animation.duration = 2;
[_scaleLabel.layer addAnimation:animation forKey:nil];
-
CAKeyframeAnimation+CALayer实现抖动动画
关键帧
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];
}];
网友评论