I am trying to have 2 animations one that increases the label's size and makes it return to its original form but I can't repeat the shrinking like I can increasing the size. How can I shrink it it on loop?
Code Block func animateLabels() { UIView.animate(withDuration: 2, delay: 0, options: .repeat, animations: { //1.5 times it's normal size self.proLabel.transform = CGAffineTransform(scaleX: 1.5, y: 1.5) }){ (finished) in UIView.animate(withDuration: 2, delay: 2, options: .repeat, animations: { self.proLabel .transform = CGAffineTransform.identity }) } }
Then, when do you stop ?
You can either set a very large value for repeat or simply :
You don't even need the completion handler
if you have an infinite repeat (it will never be called)
You can either set a very large value for repeat or simply :
Code Block func animateLabels() { UIView.animate(withDuration: 2, delay: 0, options: [.repeat, .autoreverse], animations: { self.proLabel.transform = CGAffineTransform(scaleX: 1.5, y: 1.5) }) }
You don't even need the completion handler
Code Block { (finished) in self.proLabel.transform = CGAffineTransform.identity }
if you have an infinite repeat (it will never be called)