#import "ViewController.h"
@interface ViewController ()
//連線yellowView
@property (weak, nonatomic) IBOutlet UIView *yellowView;
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
//UIView 的動畫效果: 在view的形變中加入過渡效果
}
// 連線普通動畫
- (IBAction)normalAnimation:(id)sender {
//1.開啟動畫
[UIView beginAnimations:@"normal" context:nil];
//2.設(shè)置動畫的相關(guān)屬性
//代理
[UIView setAnimationDelegate:self];
//持續(xù)時間:決定動畫速度
[UIView setAnimationDuration:10];
//重復(fù)次數(shù)
// [UIView setAnimationRepeatCount:2];
//加速方式
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
//動畫效果
_yellowView.transform = CGAffineTransformRotate(_yellowView.transform, M_PI);
//提交動畫
[UIView commitAnimations];
}
//連線Block動畫
- (IBAction)blockAnimation:(id)sender {
[UIView animateWithDuration:1 animations:^{
_yellowView.transform = CGAffineTransformRotate(_yellowView.transform, M_PI);
}completion:^(BOOL finished) {
NSLog(@"動畫完成時調(diào)用的代碼");
}];
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end
屏幕快照 2016-02-24 上午10.50.02.png