Simple code snippet today that show how to push a UIView
and obtain the same effect of a UINavigationController
as push action, choosing also the side (.fromLeft
/ .fromRight
).
We can do this using the CATransition
animations. Very simple:
func push( view: UIView, side: CATransitionSubtype = .fromRight ) {
let transition = CATransition()
transition.type = CATransitionType.push
transition.subtype = side
self.layer.add(transition, forKey: nil)
self.addSubview(view)
}
Enjoy pushing!
Latest posts by Alberto Pasca (see all)
- Unity3D – Snap object in editor grid - 3 January 2021
- Swift – UIView gradient extension - 7 December 2020
- iOS – Data Leakage: App background cache - 16 November 2020