//缩放动画 CAKeyframeAnimation(关键帧动画)
- (void) shakeToShow:(UIView *)aView
{
CAKeyframeAnimation* animation = [CAKeyframeAnimation animationWithKeyPath:@"transform"];
animation.duration = 0.6;// 动画时间
NSMutableArray *values = [NSMutableArray array];
// 前两个是控制view的大小的;
[values addObject:[NSValue valueWithCATransform3D:CATransform3DMakeScale(1.0, 1.0, 1.0)]];
[values addObject:[NSValue valueWithCATransform3D:CATransform3DMakeScale(0.8, 0.8, 1.0)]];
[values addObject:[NSValue valueWithCATransform3D:CATransform3DMakeScale(1.0, 1.0, 1.0)]];
animation.values = values;
[aView.layer addAnimation:animation forKey:nil];
}
//UIView动画方式
- (void)scaleAnimation {
[UIView animateWithDuration:0.1 animations:^{
self.transform = CGAffineTransformMakeScale(1.5, 1.5);
} completion:^(BOOL finished) {
[UIView animateWithDuration:0.1 animations:^{
self.transform = CGAffineTransformMakeScale(0.9, 0.9);
} completion:^(BOOL finished) {
[UIView animateWithDuration:0.12 animations:^{
self.transform = CGAffineTransformMakeScale(1.1, 1.1);
} completion:^(BOOL finished) {
[UIView animateWithDuration:0.12 animations:^{
self.transform = CGAffineTransformMakeScale(1.0, 1.0);
}];
}];
}];
}];
}
网友评论