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:
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:
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. . .
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 ofaddAnimation
, like this:Originally
rectLayer.opacity
is0
, and the function ofalphaAnim
is to fade it into1
, so that after setting, it will remain as1
after the animation ends.Sometimes it’s really not easy to do this, but there are alternatives:
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. . .