你的位置:首页 > 操作系统

[操作系统]iOS 简单动画 block动画


 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 }