ProductPromotion
Logo

Swift

made by https://0x3d.site

GitHub - phimage/CustomSegue: Custom segue for OSX Storyboards with slide and cross fade effects (NSViewControllerTransitionOptions)
Custom segue for OSX Storyboards with slide and cross fade effects (NSViewControllerTransitionOptions) - phimage/CustomSegue
Visit Site

GitHub - phimage/CustomSegue: Custom segue for OSX Storyboards with slide and cross fade effects (NSViewControllerTransitionOptions)

GitHub - phimage/CustomSegue: Custom segue for OSX Storyboards with slide and cross fade effects (NSViewControllerTransitionOptions)

CustomSegue

License Platform Language Issues Cocoapod

Custom segue for OSX Storyboards. Slide and cross fade effects, new customized window.

class MyViewController: NSViewController {

  override func prepareForSegue(segue: NSStoryboardSegue, sender: AnyObject?)
      if segue.identifier == "configured" {
          if let segue = segue as? PresentWithAnimatorSegue, animator = segue.animator as? TransitionAnimator {
              animator.duration = 1
              animator.transition = [.SlideDown, .Crossfade]
          }
      }
  }

TransitionAnimator transition is configured via NSViewControllerTransitionOptions, and suppress the need to use a parent controller with transitionFromViewController function.

Demo

In Example folder you can launch pod install and open Example.xcworkspace

How to use

Use PresentWithAnimatorSegue in your storyboard or use one of already configured segue: SlideDownSegue, SlideUpSegue, SlideLeftSegue, SlideRightSegue, ChildWindowSegue, ...

Configure segue

In your storyboard add an storyboard identifier to the segue.

Then in your source view controller, you can configure the segue in prepare(for segue function.

class MyViewController: NSViewController {
  override func prepare(for segue: NSStoryboardSegue, sender: AnyObject?) {
    if segue.identifier?.rawValue == "PetDetail" {
    ...

You can use Natalie to generate code about segue for your controller. With this generate code you can do

  override func prepare(for segue: NSStoryboardSegue, sender: AnyObject?) {
    if segue.identifier == "PetDetail" {
    // or better the constant generated
    if segue == MyViewController.Segue.petDetail {

You can change the duration, the transition type, ... on animator object of type TransitionAnimator

if let segue = segue as? PresentWithAnimatorSegue, animator = segue.animator as? TransitionAnimator {
  animator.duration = 1
  animator.transition = [.SlideDown, .Crossfade]
}

For ChildWindowSegue you can customize the NSWindow, which display the destination controller

if let segue = segue as? ChildWindowSegue, animator = segue.animator as? ChildWindowAnimator {
    animator.windowCustomizer = { window in
      window.styleMask = NSBorderlessWindowMask
      window.setFrameOrigin(NSPoint(...))
    }
}

:bulb: You can also put your own custom animator.

if let segue = segue as? PresentWithAnimatorSegue {
  segue.animator = MyAnimator()
}

Others segues

ReplaceWindowContentSegue

Replace contentViewController of sourceController parent NSWindow by destinationController

:bulb: You can store this segue into destinationController and call unperform on it to restore sourceController

SplitViewSegue

Segue that replace the last split view item or add a new one into the sourceController parent (NSSplitViewController)

Set replace to false on segue, to add a new split view item.

DismissSegue

Segue to dismiss current from controller

Allow to display in storyboard the action as segue instead of simple IBAction

TransitionFromViewSegue

Segue using parent controller of source and transitionFromViewController function

:warning: parentViewController must be set and the same for the sourceController and destinationController

TablePopoverSegue

Show destinationController in a popover with a position relative to the selected table row

:warning: You must set the tableView into segue object (do it in prepareForSegue)

:bulb: You can display detail about selected row in a nice way. So in prepareForSegue get table view selected row and pass data to destinationController

Present view controller utility method

Little utility method added to NSViewController using new enum PresentationMode.

viewController.present(.asSheet)
viewController.present(.asModalWindow)
viewController.present(.segue(segueIdentifier: "id"))
viewController.present(.animator(animator: MyAnimator()))
viewController.present(.asPopover(...

:warning: parentViewController must be set

Installation

Using CocoaPods

CocoaPods is a centralized dependency manager for Objective-C and Swift. Go here to learn more.

  1. Add the project to your Podfile.

    use_frameworks!
    
    pod 'CustomSegue'
    
  2. Run pod install and open the .xcworkspace file to launch Xcode.

Using Carthage

Carthage is a decentralized dependency manager for Objective-C and Swift.

  1. Add the project to your Cartfile.

    github "phimage/CustomSegue"
    
  2. Run carthage update and follow the additional steps in order to add Prephirences to your project.

More Resources
to explore the angular.

mail [email protected] to add your project or resources here ๐Ÿ”ฅ.

Related Articles
to learn about angular.

FAQ's
to learn more about Angular JS.

mail [email protected] to add more queries here ๐Ÿ”.

More Sites
to check out once you're finished browsing here.

0x3d
https://www.0x3d.site/
0x3d is designed for aggregating information.
NodeJS
https://nodejs.0x3d.site/
NodeJS Online Directory
Cross Platform
https://cross-platform.0x3d.site/
Cross Platform Online Directory
Open Source
https://open-source.0x3d.site/
Open Source Online Directory
Analytics
https://analytics.0x3d.site/
Analytics Online Directory
JavaScript
https://javascript.0x3d.site/
JavaScript Online Directory
GoLang
https://golang.0x3d.site/
GoLang Online Directory
Python
https://python.0x3d.site/
Python Online Directory
Swift
https://swift.0x3d.site/
Swift Online Directory
Rust
https://rust.0x3d.site/
Rust Online Directory
Scala
https://scala.0x3d.site/
Scala Online Directory
Ruby
https://ruby.0x3d.site/
Ruby Online Directory
Clojure
https://clojure.0x3d.site/
Clojure Online Directory
Elixir
https://elixir.0x3d.site/
Elixir Online Directory
Elm
https://elm.0x3d.site/
Elm Online Directory
Lua
https://lua.0x3d.site/
Lua Online Directory
C Programming
https://c-programming.0x3d.site/
C Programming Online Directory
C++ Programming
https://cpp-programming.0x3d.site/
C++ Programming Online Directory
R Programming
https://r-programming.0x3d.site/
R Programming Online Directory
Perl
https://perl.0x3d.site/
Perl Online Directory
Java
https://java.0x3d.site/
Java Online Directory
Kotlin
https://kotlin.0x3d.site/
Kotlin Online Directory
PHP
https://php.0x3d.site/
PHP Online Directory
React JS
https://react.0x3d.site/
React JS Online Directory
Angular
https://angular.0x3d.site/
Angular JS Online Directory