創(chuàng)建好一個(gè)簡單的UIView
創(chuàng)建屬性
@interface ViewController ()
@property (weak, nonatomic) IBOutlet UIView *showView;
@end
//點(diǎn)擊屏幕調(diào)用動(dòng)畫方法
-(void)touchesBegan:(NSSet*)touches withEvent:(UIEvent *)event
{
? ? [UIView animateWithDuration:1 delay:0.0 options:kNilOptions
? ? animations:^{
? ? ? ? ?//動(dòng)畫效果,將位置的self.showView的位置轉(zhuǎn)移到{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");?
? ? }];
}