I am using this line of code to dismiss my view controller self.dismiss(animated: true, completion: nil)
, but I do not like the current animation. Instead I want to slide from left to right. Below is my attempt to test out an animation, but does not work.
UIView.animate(withDuration: 1.0, delay: 0.0, options: UIViewAnimationOptions.curveEaseIn, animations: {
let transition = CATransition()
transition.duration = 10
transition.type = kCATransitionPush
transition.subtype = kCATransitionFromLeft
self.view.layer.add(transition, forKey: kCATransition)
self.dismiss(animated: false, completion: nil)
}, completion: nil)
When it comes time to dismiss a presented view controller, the preferred approach is to let the presenting view controller dismiss it. In other words, whenever possible, the same view controller that presented the view controller should also take responsibility for dismissing it.
A UIViewController is an object which manages the view hierarchy of the UIKit application. The UIViewController defines the shared behavior and properties for all types of ViewController that are used in the iOS application. The UIViewController class inherits the UIResponder class.
let transition: CATransition = CATransition()
transition.duration = 0.5
transition.timingFunction = CAMediaTimingFunction(name: CAMediaTimingFunctionName.easeInEaseOut)
transition.type = CATransitionType.reveal
transition.subtype = CATransitionSubtype.fromRight
self.view.window!.layer.add(transition, forKey: nil)
self.dismiss(animated: false, completion: nil)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With