modifyAnimations(withRepeatCount:autoreverses:animations:)
Repeats the specified animations a specific number of times, optionally running the animation forward and backward.
Declaration
class func modifyAnimations(withRepeatCount count: CGFloat, autoreverses: Bool, animations: () -> Void)Parameters
- count:
The number of times to repeat the animations.
- autoreverses:
A Boolean value that indicates whether the animations run forward and backward.
- animations:
The animations to perform.
Discussion
You must call this method from within an enclosing animation block. The inverse nesting, calling animate(withDuration:animations:) from inside the modifyAnimations(withRepeatCount:autoreverses:animations:) block, doesn’t work.
UIView.animate(withDuration: 1.0) {
UIView.modifyAnimations(withRepeatCount: 2, autoreverses: true) {
// Set view properties.
}
}See Also
Animating views
animate(_:changes:completion:)animate(springDuration:bounce:initialSpringVelocity:delay:options:animations:completion:)animate(withDuration:delay:options:animations:completion:)animate(withDuration:animations:completion:)animate(withDuration:animations:)transition(with:duration:options:animations:completion:)transition(from:to:duration:options:completion:)animateKeyframes(withDuration:delay:options:animations:completion:)addKeyframe(withRelativeStartTime:relativeDuration:animations:)perform(_:on:options:animations:completion:)animate(withDuration:delay:usingSpringWithDamping:initialSpringVelocity:options:animations:completion:)performWithoutAnimation(_:)