UIViewController custom transitions with animateWithDuration in Swift

So ... In truth, I'm almost blindly looking at the documentation. I really don't understand why there is no sample code illustrating the use of certain methods. But yes, stop whining from me.

I have a view controller that matches UIViewControllerTransitioningDelegate and UIViewControllerAnimatedTransitioning. I have several animations (using facebook pop) that substantially fill some of the presentation elements. After completing these animations, I want to move on to the next view controller.

I redefined prepareForSegue like this:

override func prepareForSegue(segue: UIStoryboardSegue!, sender: AnyObject!) {

      self.transitioningDelegate = self;

      let targetViewController = self.storyboard.instantiateViewControllerWithIdentifier("chooseSigilViewController") as UIViewController;

      self.presentViewController(targetViewController, animated: true, completion: nil);

      // slide out ui elements in the current UIViewController
      slideLabelsOut(greetingsLabel, nameUtilityLabel);
      slideTextFieldOut(inputPlayerNameTextField);
      slideProceedButtonOut(sender as UIButton); }

I than adjust the transition duration and the actual animation ... I have a problem with this line:

UIView.animateWithDuration(self.transitionDuration(transitionContext), animations: <#(() -> Void)?#>, completion: <#((Bool) -> Void)?#>)

: : .

Obj-C:

^{ // code goes here }

, . , , ? ^//" >

+4
1

- :

UIView.animateWithDuration(self.transitionDuration(transitionContext), delay: 0, options: .CurveLinear, animations: {
    // Your animation
}, completion: {
    (finished: Bool) in
    // Your completion
})
+3

Source: https://habr.com/ru/post/1544787/


All Articles