ios - 为什么当 Core Animation 完成时,layer 又会恢复到原先的状态?
伊谢尔伦
伊谢尔伦 2017-04-17 13:51:25
0
1
670
伊谢尔伦
伊谢尔伦

小伙看你根骨奇佳,潜力无限,来学PHP伐。

reply all(1)
巴扎黑

Because it’s just a performance animation, it doesn’t really modify anything, and it’s different from those UIView.animateXXX things. If you want to retain the effect, you need to set it yourself outside of addAnimation, like this:

rectLayer.addAnimation(alphaAnim, forKey: "alphaAnim")
rectLayer.opacity = 1

Originally rectLayer.opacity is 0, and the function of alphaAnim is to fade it into 1, so that after setting, it will remain as 1 after the animation ends.

Sometimes it’s really not easy to do this, but there are alternatives:

alphaAnim.removedOnCompletion = false
alphaAnim.fillMode = kCAFillModeForwards

Let the animation not be removed after it is completed, and stay in the state where the animation ends. But remember that the original settings of the animated elements have not changed in any way due to animation, otherwise it will be all kinds of mess. . .

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template