I have a iOS application with a tab bar at the bottom, like this:
The white circle at the center of the tab bar pulsates by fading in and out repeatedly. Here's the code that does the pulsate animation:
UIView.animateKeyframes(withDuration: 1.4, delay: 0, options: [.repeat, .autoreverse], animations: {
UIView.addKeyframe(withRelativeStartTime: 0, relativeDuration: 0.7, animations: {
self.recordingPulsatingCircleView?.alpha = 1
})
UIView.addKeyframe(withRelativeStartTime: 0.7, relativeDuration: 1.4, animations: {
self.recordingPulsatingCircleView?.alpha = 0
})
}, completion: nil)
The problem is that when the tab bar disappears, by, for example, being hidden behind another view, or when I click the home button and bring back the app again, the animation stops, and the white circle disappears, like this:
I expect it to continue animating because I set .repeat
as one of the options
. Any help?