3.3UIViewAnimation视图动画

UIViewAnimation视图动画

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    [self UIViewAboutAnimation];
}


#pragma mark - UIView  animation
- (void)UIViewAboutAnimation{

    UIView *v = [[UIView alloc] initWithFrame:CGRectMake(20, 40, 200, 200)];
    v.backgroundColor = [UIColor redColor];
    [self.view addSubview:v];
#if 0
    /***非Block动画***/
    //g
    //开始动画
  /*  [UIView beginAnimations:nil context:nil];
    //设置动画的相关参数
    //设置动画的延迟时间
    [UIView setAnimationDelay:1];
    //设置动画的播放时间
    [UIView setAnimationDuration:3];
    //设置动画的重复次数
    [UIView setAnimationRepeatCount:1];
    [UIView setAnimationDelegate:self];
    //
    [UIView setAnimationDidStopSelector:@selector(didStopAnimation)];

    //设置动画执行完毕之后 view的执行结果
    v.backgroundColor = [UIColor blueColor];
    v.frame = [[UIScreen mainScreen] bounds];
       //提交动画
    [UIView commitAnimations];*/
#else
//    UIViewAnimationOptionBeginFromCurrentState
//    UIViewAnimationOptionRepeat
    /**block动画**/
  
    [UIView animateWithDuration:3 delay:1 options:UIViewAnimationOptionBeginFromCurrentState animations:^{
        //执行完动画 视图的结果
        v.backgroundColor = [UIColor yellowColor];
        v.frame = [[UIScreen mainScreen] bounds];
    } completion:^(BOOL finished) {
        //动画结束之后
#warning UIAlertView
        UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"动画结束" message:@"真的结束了" delegate:self cancelButtonTitle:@"是" otherButtonTitles:@"否", nil];
        [alert show];
    }];
    
    
    
    
#endif

}

- (void)didStopAnimation{
    NSLog(@"动画结束!");
    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"动画结束" message:@"真的结束了" delegate:self cancelButtonTitle:@"是" otherButtonTitles:@"否", nil];
    [alert show];
}

你可能感兴趣的:(3.3UIViewAnimation视图动画)