ios开发——视图动画(动画开始与结束设置)

- (void)onClick:(id)sender {

    

    //动画开始将按钮设置为不可见

    self.button.alpha = 0.0;

    [UIView animateWithDuration:1.5 animations:^{

        CGRect frame = self.ball.frame;

        frame.origin.y += 200 * flag;

        flag *= -1; //取反

        self.ball.frame = frame;

    } completion:^(BOOL finished) {

        NSLog(@"动画结束了。");

        [self viewAnimationDone];

    }];

    

}


//动画结束之后的处理

- (void)viewAnimationDone {

    //为按钮显示过程添加动画

    [UIView animateWithDuration:1 animations:^{

        //动画结束后将按钮设置为可见

        self.button.alpha = 1.0;

    }];

}

猜你喜欢

转载自blog.csdn.net/sndongcheng/article/details/81234334