作者:茶不离 | 来源:互联网 | 2023-01-02 16:16
今天做项目过程中,需要切换背景图片,但是由于直接切换十分生硬,因此使用如下动画,可以时图片改变时有渐变的效果。
- "white-space:pre"> CATransition *transition = [CATransition animation];
- transition.duration = 0.3;
- transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
- transition.type = kCATransitionFade;
- [self.backgroundImage.layer addAnimation:transition forKey:@"a"];
- [self.backgroundImage setImage:self.basicImage];
-
转载:http://blog.csdn.net/ksws0393238aa/article/details/21297823