1 - (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{
2 UIView * view = [[UIView alloc]initWithFrame:CGRectMake(100, 100, 100, 100)];
3 view.backgroundColor = [UIColor orangeColor];
4 view.alpha = 1;
5 [self.view addSubview:view];
6 //动画持续时间为五秒
7 [UIView animateWithDuration:5 animations:^{
8 view.alpha = 0;
9 }completion:^(BOOL finished) {//当动画结束后进行的操作
10 //动画时间为一秒
11 [UIView animateWithDuration:1 animations:^{
12 view.alpha = 1;
13 } completion:^(BOOL finished) {
14 view.backgroundColor = [UIColor blueColor];
15 }];
16 }];
17 }