标签:
注释:
duration 动画完成时间,
delay 动画延长时间,可以理解为动画速度的时间控制
一,利用
CGAffineTransformMakeScale来做图形的缩放效果
view.transform = CGAffineTransformMakeScale(1, 1); [UIView animateKeyframesWithDuration:duration/3 delay:delay options:0 animations:^{ // End view.transform = CGAffineTransformMakeScale(1.2, 1.2); } completion:^(BOOL finished) { [UIView animateKeyframesWithDuration:duration/3 delay:0 options:0 animations:^{ // End view.transform = CGAffineTransformMakeScale(0.9, 0.9); } completion:^(BOOL finished) { [UIView animateKeyframesWithDuration:duration/3 delay:0 options:0 animations:^{ // End view.transform = CGAffineTransformMakeScale(1, 1); } completion:^(BOOL finished) { }]; }]; }];
二,结合alpha来做闪现缩放
view.alpha = 1; view.transform = CGAffineTransformMakeScale(0.9, 0.9); [UIView animateKeyframesWithDuration:duration/3 delay:delay options:0 animations:^{ // End view.alpha = 0; view.transform = CGAffineTransformMakeScale(1.2, 1.2); } completion:^(BOOL finished) { }];
三,利用
CGAffineTransformMakeTranslation来做view的移动动画
view.transform = CGAffineTransformMakeTranslation(CGRectGetWidth([UIScreen mainScreen].bounds), 0); [UIView animateKeyframesWithDuration:duration/4 delay:delay options:0 animations:^{ // End view.transform = CGAffineTransformMakeTranslation(-10, 0); } completion:^(BOOL finished) { [UIView animateKeyframesWithDuration:duration/4 delay:0 options:0 animations:^{ // End view.transform = CGAffineTransformMakeTranslation(5, 0); } completion:^(BOOL finished) { [UIView animateKeyframesWithDuration:duration/4 delay:0 options:0 animations:^{ // End view.transform = CGAffineTransformMakeTranslation(-2, 0); } completion:^(BOOL finished) { [UIView animateKeyframesWithDuration:duration/4 delay:0 options:0 animations:^{ // End view.transform = CGAffineTransformMakeTranslation(0, 0); } completion:^(BOOL finished) { }]; }]; }]; }];
当然以上这些都是可以相互组合来做更炫酷的动画,具体只需要了解响应的原理,便可根据需要做出自定义的动画
标签:
原文地址:http://www.cnblogs.com/sixindev/p/4810579.html