I have the following code want to fade in and out a UILabel. But I just want it to repeat the fade in and out 5 times. My question is how to set the animation only repeat 3 times?
func savingIcon(){
Loading.hidden=false
UIView.animateWithDuration(1.0,
delay: 0.0,
options: [ .CurveEaseInOut],
animations: {
self.Loading.alpha=0.0;
self.Loading.alpha=1.0;
self.Loading.alpha=0.0;
self.Loading.alpha=1.0;
self.Loading.alpha=0.0;
},
completion: { finished in
print("Save done")
self.Loading.hidden=true
})
}
If you want to repeat your animation block 5 times, try doing:
UIView.animateWithDuration(1.0,
delay: 0.5,
options: [ .CurveEaseInOut, .Repeat],
animations: {
UIView.setAnimationRepeatCount(5)
self.Loading.alpha=0.0;
self.Loading.alpha=1.0;
self.Loading.alpha=0.0;
self.Loading.alpha=1.0;
self.Loading.alpha=0.0;
},
completion: { finished in
print("Save done")
self.Loading.hidden=true
})
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With