UIViewController Animation ios?

Tratando de crear algo como a continuación en Objective-C, esto está disponible en Swift. Intenté utilizar puentes, etc., para usar este código con mi proyecto Objective C, pero está teniendo problemas de import.

En Objective-C probé las cosas a continuación y parcialmente funciona para UIView, pero creo que necesito agregar transiciones para completar UIViewController.

introduzca la descripción de la imagen aquí

Lo que intenté

- (IBAction)menuButtonPressed:(id)sender { if ([self.delegate respondsToSelector:@selector(menuButtonPressed)]) { [self.delegate menuButtonPressed]; } if (!isVertical) { [UIView animateWithDuration: 0.6 delay: 0.0 usingSpringWithDamping: 0.3 initialSpringVelocity: .8 options: 0 animations: ^ { self.transform = CGAffineTransformTranslate(self.transform, -240, 0); self.transform = CGAffineTransformRotate(self.transform, 90 * M_PI / 180); self.transform = CGAffineTransformTranslate(self.transform, 240, 0); } completion:^(BOOL finished) { isVertical = YES; } ]; }else{ [UIView animateWithDuration: 0.45 delay: 0.0 usingSpringWithDamping: 0.44 initialSpringVelocity: .8 options: 0 animations: ^ { self.transform = CGAffineTransformTranslate(self.transform, -240, 0); self.transform = CGAffineTransformRotate(self.transform, -90 * M_PI / 180); self.transform = CGAffineTransformTranslate(self.transform, 240, 0); } completion:^(BOOL finished) { isVertical = NO; } ]; } } 

Cualquier input será útil.

Aquí hay una implementación muy simple que puede usar para animar las transiciones entre los controlleres de vista. Básicamente, puedes usar la misma esencia de animation si quieres usarlo con UIViews.

 let generateRandomColor: Void -> UIColor = { let networking = CGFloat(arc4random_uniform(255)) / 255.0 let green = CGFloat(arc4random_uniform(255)) / 255.0 let blue = CGFloat(arc4random_uniform(255)) / 255.0 return UIColor(networking:networking, green: green, blue: blue, alpha: 1) } class SlideAnimationController: NSObject, UIViewControllerAnimatedTransitioning { let presenting: Bool init(presenting: Bool) { self.presenting = presenting super.init() } func transitionDuration(transitionContext: UIViewControllerContextTransitioning?) -> NSTimeInterval { return 0.5 } func animateTransition(transitionContext: UIViewControllerContextTransitioning) { let containerView = transitionContext.containerView()! let fromView = transitionContext.viewForKey(UITransitionContextFromViewKey)! let toView = transitionContext.viewForKey(UITransitionContextToViewKey)! var animatingView: UIView var initialTransform: CGAffineTransform var finalTransform: CGAffineTransform if presenting { containerView.addSubview(toView) animatingView = toView initialTransform = CGAffineTransformMakeRotation(CGFloat(-M_PI_2)) finalTransform = CGAffineTransformIdentity } else { containerView.insertSubview(toView, belowSubview: fromView) animatingView = fromView initialTransform = CGAffineTransformIdentity finalTransform = CGAffineTransformMakeRotation(CGFloat(-M_PI_2)) } animatingView.layer.anchorPoint = CGPointMake(0, 0) animatingView.frame = containerView.bounds animatingView.transform = initialTransform UIView.animateWithDuration(transitionDuration(transitionContext), delay: 0, usingSpringWithDamping: 0.6, initialSpringVelocity: 16, options: UIViewAnimationOptions.CurveLinear, animations: { () -> Void in animatingView.transform = finalTransform }) { _ in toView.layer.anchorPoint = CGPointMake(0.5, 0.5) toView.frame = containerView.bounds transitionContext.completeTransition(true) } } } class PresentedViewController: UIViewController { override func viewDidLoad() { super.viewDidLoad() view.backgroundColor = generateRandomColor() let tapGestureRecognizer = UITapGestureRecognizer(target: self, action: "tapped") view.addGestureRecognizer(tapGestureRecognizer) } func tapped() { dismissViewControllerAnimated(true, completion: nil) } } class TestViewController: UIViewController, UIViewControllerTransitioningDelegate { override func viewDidLoad() { super.viewDidLoad() view.backgroundColor = generateRandomColor() let tapGestureRecognizer = UITapGestureRecognizer(target: self, action: "tapped") definesPresentationContext = true view.addGestureRecognizer(tapGestureRecognizer) } func tapped() { let presentedViewController = PresentedViewController() presentedViewController.modalPresentationStyle = UIModalPresentationStyle.CurrentContext presentedViewController.transitioningDelegate = self presentViewController(presentedViewController, animated: true, completion: nil) } func animationControllerForPresentedController(presented: UIViewController, presentingController presenting: UIViewController, sourceController source: UIViewController) -> UIViewControllerAnimatedTransitioning? { return SlideAnimationController(presenting: true) } func animationControllerForDismissedController(dismissed: UIViewController) -> UIViewControllerAnimatedTransitioning? { return SlideAnimationController(presenting: false) } }