這是我們實(shí)現(xiàn)動(dòng)畫效果最簡(jiǎn)單的方法了,可以實(shí)現(xiàn)簡(jiǎn)單的平移、縮放和旋轉(zhuǎn)功能,平常我們基本上對(duì)于簡(jiǎn)單的平移使用該方法來(lái)完成
對(duì)應(yīng)實(shí)現(xiàn)UIView Animation的文件是FirstViewController
首先,我們定義一個(gè)UIView屬性
@property (nonatomic, strong) UIView *myView;
并將其添加到界面上
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view.
self.title = @"UIView Animation實(shí)現(xiàn)動(dòng)畫效果";
self.view.backgroundColor = [UIColor whiteColor];
self.navigationController.navigationBar.translucent = NO;
[self.view addSubview:self.myView];
self.myView.center = self.view.center;
}
- (UIView *)myView {
if (_myView) {
return _myView;
}
_myView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 200, 100)];
_myView.backgroundColor = [UIColor redColor];
return _myView;
}
點(diǎn)擊屏幕時(shí),執(zhí)行相應(yīng)的動(dòng)畫代碼
- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
[UIView animateWithDuration:1 animations:^{
//最終的myView的大小和顏色
self.myView.frame = CGRectMake(200, 300, 100, 100);
self.myView.backgroundColor = [UIColor blueColor];
} completion:^(BOOL finished) {
//動(dòng)畫完成時(shí)可以執(zhí)行一些我們想要的操作
NSLog(@"動(dòng)畫效果完成");
}];
}
這種方式比較簡(jiǎn)單,就沒(méi)有過(guò)多研究,最終的效果圖為:

UIView animation動(dòng)畫效果.gif
iOS動(dòng)畫效果的探究二:UIView Animation實(shí)現(xiàn)動(dòng)畫
iOS動(dòng)畫效果三:CABAsicAnimation實(shí)現(xiàn)平移、旋轉(zhuǎn)和放大
ios動(dòng)畫效果四:使用Pop框架實(shí)現(xiàn)彈簧效果
iOS動(dòng)畫效果五:CABasicAnimation實(shí)現(xiàn)繞定點(diǎn)旋轉(zhuǎn)的效果]
iOS動(dòng)畫效果六:實(shí)現(xiàn)自定義的push轉(zhuǎn)場(chǎng)動(dòng)畫
iOS動(dòng)畫效果七:實(shí)現(xiàn)自定義present轉(zhuǎn)場(chǎng)動(dòng)畫效果