Basic Transitions for multiple UIViews at the same time
UIView Group Transitions
Demo
UIView.groupTransition(
with: [label, aButton, ...], // Add all your views here
duration: 0.3,
delay: 0.0,
type: .fade, // .fade, .moveIn, .push, .reveal
subtype: nil,
timing: .easeInOut // .linear, .easeIn, .easeOut, .easeInOut
) {
// Your animations go here...
self.label.text = "Hello World"
self.aButton.setImage(UIImage(named: "cat"), for: .normal)
} completion: { completed in
print("Animation completed!")
}
The groupTransition
method allows you to add the same transition animation to multiple views specified in an Array. You don’t have to write multiple UIView.transition
blocks instead.
How to use
- Clone project
git clone https://github.com/Thisura98/uiview-group-transition.git
-
Open uiview-group-transition/transitiontest
-
Copy
UIView+Transition.swift
file in to your project -
Use as a
UIView
extension (see demo above)