// 在规定时间 慢慢完成操作
[UIView animateWithDuration:1 animations:^{
self.button.backgroundColor = [UIColor orangeColor];
} completion:^(BOOL finished) {
// 完成回调后 还原来颜色
[UIView animateWithDuration:1 animations:^{
self.button.backgroundColor = [UIColor clearColor];
}];
}];
如果需要重复多次推荐这种方法
/**
animateWithDuration 多少时间完成动画
delay 延迟多久开始做动画
*/
[UIView animateWithDuration:1 delay:0 options:UIViewAnimationOptionAutoreverse animations:^{
// 动画重复次数
[UIView setAnimationRepeatCount:3];
self.button.backgroundColor = [UIColor purpleColor];
} completion:^(BOOL finished) {
// 完成回调后 还原颜色
[UIView animateWithDuration:1 animations:^{
self.button.backgroundColor = [UIColor clearColor];
}];
}];