Contents

transition(from:to:options:completionHandler:)

Performs a transition between two sibling child view controllers of the view controller.

Declaration

func transition(from fromViewController: NSViewController, to toViewController: NSViewController, options: NSViewController.TransitionOptions = [], completionHandler completion: (@Sendable () -> Void)? = nil)
func transition(from fromViewController: NSViewController, to toViewController: NSViewController, options: NSViewController.TransitionOptions = []) async

Parameters

  • fromViewController:

    A child view controller whose view is visible in the view controller’s view hierarchy.

  • toViewController:

    A child view controller whose view is not in the view controller’s view hierarchy.

  • options:

    A bitmask of options that specify how you want to perform the transition animation. For the options, see the Transitionoptions enumeration.

  • completion:

    A block called immediately after the transition animation completes.

Discussion

Use this method to transition between sibling child view controllers owned by a parent view controller (which is the receiver of this method).

This method adds the view in the toViewController view controller to the superview of the view in the fromViewController view controller. Likewise, this method removes the fromViewController view from the parent view controller’s view hierarchy at the appropriate time. It is important to allow this method to add and remove these views.

To create a parent/child relationship between view controllers, use the addChild(_:) method or the insertChild(_:at:) method.

See Also

Managing Child View Controllers in a Custom Container