创建好一个简单的UIView
创建属性
@interface ViewController ()
@property (weak, nonatomic) IBOutlet UIView *showView;
@end
//点击屏幕调用动画方法
-(void)touchesBegan:(NSSet*)touches withEvent:(UIEvent *)event
{
[UIView animateWithDuration:1 delay:0.0 options:kNilOptions
animations:^{
//动画效果,将位置的self.showView的位置转移到{200,200},{180,100}
//{100,100},{180,100} -> {100,200},{180,100}
self.showView.frame = CGRectMake(100, 200, 180, 100);
//改变颜色
self.showView.backgroundColor = [UIColor greenColor];
}
completion:^(BOOL finished){NSLog(@"Done");
}];
}