-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathPresentingViewController.swift
More file actions
51 lines (33 loc) · 1.67 KB
/
PresentingViewController.swift
File metadata and controls
51 lines (33 loc) · 1.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
//
// PresentingViewController.swift
// Example
//
// Created by Hirohisa Kawasaki on 10/13/15.
// Copyright © 2015 Hirohisa Kawasaki. All rights reserved.
//
import UIKit
import Union
class PresentingViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
navigationItem.rightBarButtonItem = UIBarButtonItem(title: "overlay", style: .Plain, target: self, action: "showPresentation")
}
func showPresentation() {
let viewController = ProfileViewController()
let navigationController = UINavigationController(rootViewController: viewController)
navigationController.modalPresentationStyle = .Custom
navigationController.transitioningDelegate = self
presentViewController(navigationController, animated: true, completion: nil)
}
}
extension PresentingViewController: UIViewControllerTransitioningDelegate {
func presentationControllerForPresentedViewController(presented: UIViewController, presentingViewController presenting: UIViewController, sourceViewController source: UIViewController) -> UIPresentationController? {
return PresentationController(presentedViewController: presented, presentingViewController: presenting)
}
func animationControllerForPresentedController(presented: UIViewController, presentingController presenting: UIViewController, sourceController source: UIViewController) -> UIViewControllerAnimatedTransitioning? {
return Union.Presenter.animate()
}
func animationControllerForDismissedController(dismissed: UIViewController) -> UIViewControllerAnimatedTransitioning? {
return Union.Presenter.animate()
}
}