Wednesday, July 1, 2026
HomeiOS Developmentios - Repeating Keyframe animation N occasions

ios – Repeating Keyframe animation N occasions

[ad_1]

I presently have key body animation code like so:

UIView.animateKeyframes(withDuration: 1, delay: 0, choices: [.repeat, .allowUserInteraction], animations: {
    UIView.setAnimationRepeatCount(3)
    UIView.addKeyframe(withRelativeStartTime: 0.0, relativeDuration: 0.4, animations: {
        self.containerView.backgroundColor = Theme.blue10
    })

    UIView.addKeyframe(withRelativeStartTime: 0.4, relativeDuration: 0.2, animations: {
        self.containerView.backgroundColor = Theme.blue10
    })

    UIView.addKeyframe(withRelativeStartTime: 0.6, relativeDuration: 0.4, animations: {
        self.containerView.backgroundColor = backgroundColor
    })
}, completion: nil)

Nonetheless setAnimationRepeatCount has been deprecated in iOS13. How would I am going about repeating a key body animation with out setAnimationRepeatCount?

I appeared into UIViewPropertyAnimator however there does not appear to be an choice to repeat these animations n occasions.

[ad_2]

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments