• Stars
    star
    124
  • Rank 278,209 (Top 6 %)
  • Language
    Swift
  • License
    MIT License
  • Created almost 8 years ago
  • Updated about 5 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

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(...))
    }
}

πŸ’‘ 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

πŸ’‘ 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

⚠️ 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

⚠️ You must set the tableView into segue object (do it in prepareForSegue)

πŸ’‘ 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(...

⚠️ 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 Repositories

1

Prephirences

Prephirences is a Swift library that provides useful protocols and convenience methods to manage application preferences, configurations and app-state. UserDefaults
Swift
568
star
2

Erik

Erik is an headless browser based on WebKit. An headless browser allow to run functional tests, to access and manipulate webpages using javascript.
Swift
564
star
3

CallbackURLKit

Implementation of x-callback-url (Inter app communication) in swift
Swift
323
star
4

morphi

Shapes for SwiftUI β™‘β˜Ύ
Swift
71
star
5

Arithmosophi

A set of protocols for Arithmetic, Statistics and Logical operations
Swift
66
star
6

ApplicationGroupKit

Share informations betweens your applications and your extensions using group identifier
Swift
38
star
7

Alamofire-Prephirences

Remote preference and configuration for your application
Swift
22
star
8

MacModelDump

Dump apple website to get mac model identifier and image url
Swift
21
star
9

XcodeProjKit

Parse project file and write it to open step format.
Swift
14
star
10

CryptoPrephirences

Add some encryption to your sensitive preferences
Swift
11
star
11

Phiole

Allow to write or read from standards stream or files for script or CLI application
Swift
8
star
12

SLF4Swift

Simple Logging Facade for Swift serves as a simple facade for logging frameworks allowing the end user to plug in the desired logging framework at deployment time
Swift
8
star
13

Notarize

Command line utility to notarize apple application
Swift
8
star
14

ValueTransformerKit

ValueTransformer toolkit for swift
Swift
8
star
15

AlertController

An NSViewController to display an alert message to the user. This class replaces the NSAlert class.
Swift
8
star
16

MomXML

Create or parse CoreData managed object model XMLs
Swift
6
star
17

RandomDistributionKit

RandomKit extension to produce random numbers using different distribution
Swift
5
star
18

PhiLipsStack

(do not use) PhiLipsStack aims to create a CoreData stack from model to context and provide some functions on your managed object which use by default the default stack context but not only
Swift
5
star
19

Alamofire-YamlSwift

Add Yaml response serializer to Alamofire
Swift
4
star
20

plistconvert

Convert plist from different format: xml, json, binary, openStep
Shell
3
star
21

action-swift-cli-build

Build swift cli tool on macOS or ubuntu
3
star
22

FileZipKit

FileKit and ZipFoundation utility methods
Swift
3
star
23

NotarizeProcess

Utility object to launch `xcrun altool` to get notarization information
Swift
3
star
24

punic

Add third party project sources into your workspace instead of Carthage binary
Swift
3
star
25

sebulba

Swift command line to remove de-integrate reference to cocoa pods
Swift
2
star
26

Appify

Generate simple macOS `.app` from Swift Package `.executable`.
Swift
2
star
27

swift-cli-template

Shell
2
star
28

tanit

Command line application to manage Carthage binaries
Swift
1
star
29

NotarizationInfo

Decode info from apple notarization process
Swift
1
star
30

NotarizationAuditLog

Decode JSON audit log from notarization process
Swift
1
star
31

phimage

1
star
32

xprojup

Swift
1
star
33

cd2sql

Convert CoreData model into SQL
Swift
1
star