Compare commits
9 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 05ba026c1f | |||
| b3f49a2a94 | |||
| c3aa4dc17e | |||
| d9f67b57f8 | |||
| 962d1a937d | |||
| bc6c7ff45e | |||
| ec7abd4a2a | |||
| 6904e0916a | |||
| 90ee3d35da |
File diff suppressed because it is too large
Load Diff
BIN
Binary file not shown.
@@ -7,7 +7,10 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
|
||||
|
||||
|
||||
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
|
||||
self.launch(rootViewController: Controller())
|
||||
|
||||
let navigationController = UINavigationController(rootViewController: Controller())
|
||||
self.launch(rootViewController: navigationController)
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@ class Controller: UIViewController {
|
||||
let transitionDelegate = SPStorkTransitioningDelegate()
|
||||
modal.transitioningDelegate = transitionDelegate
|
||||
modal.modalPresentationStyle = .custom
|
||||
present(modal, animated: true, completion: nil)
|
||||
self.present(modal, animated: true, completion: nil)
|
||||
}
|
||||
|
||||
@objc func presentModalTableViewController() {
|
||||
@@ -38,6 +38,6 @@ class Controller: UIViewController {
|
||||
let transitionDelegate = SPStorkTransitioningDelegate()
|
||||
modal.transitioningDelegate = transitionDelegate
|
||||
modal.modalPresentationStyle = .custom
|
||||
present(modal, animated: true, completion: nil)
|
||||
self.present(modal, animated: true, completion: nil)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,6 +42,13 @@ class SPStorkIndicatorView: UIView {
|
||||
}
|
||||
}
|
||||
|
||||
var color: UIColor = UIColor.init(red: 202/255, green: 201/255, blue: 207/255, alpha: 1) {
|
||||
didSet {
|
||||
self.leftView.backgroundColor = self.color
|
||||
self.rightView.backgroundColor = self.color
|
||||
}
|
||||
}
|
||||
|
||||
private var leftView: UIView = UIView()
|
||||
private var rightView: UIView = UIView()
|
||||
|
||||
@@ -50,8 +57,7 @@ class SPStorkIndicatorView: UIView {
|
||||
self.backgroundColor = UIColor.clear
|
||||
self.addSubview(self.leftView)
|
||||
self.addSubview(self.rightView)
|
||||
self.leftView.backgroundColor = UIColor.init(red: 202/255, green: 201/255, blue: 207/255, alpha: 1)
|
||||
self.rightView.backgroundColor = UIColor.init(red: 202/255, green: 201/255, blue: 207/255, alpha: 1)
|
||||
self.color = UIColor.init(red: 202/255, green: 201/255, blue: 207/255, alpha: 1)
|
||||
}
|
||||
|
||||
required init?(coder aDecoder: NSCoder) {
|
||||
|
||||
+4
@@ -26,6 +26,7 @@ class SPStorkPresentationController: UIPresentationController, UIGestureRecogniz
|
||||
var isSwipeToDismissEnabled: Bool = true
|
||||
var isTapAroundToDismissEnabled: Bool = true
|
||||
var showIndicator: Bool = true
|
||||
var indicatorColor: UIColor = UIColor.init(red: 202/255, green: 201/255, blue: 207/255, alpha: 1)
|
||||
var customHeight: CGFloat? = nil
|
||||
var transitioningDelegate: SPStorkTransitioningDelegate?
|
||||
|
||||
@@ -82,6 +83,7 @@ class SPStorkPresentationController: UIPresentationController, UIGestureRecogniz
|
||||
guard let containerView = self.containerView, let presentedView = self.presentedView, let window = containerView.window else { return }
|
||||
|
||||
if self.showIndicator {
|
||||
self.indicatorView.color = self.indicatorColor
|
||||
presentedView.addSubview(self.indicatorView)
|
||||
}
|
||||
self.updateLayoutIndicator()
|
||||
@@ -268,6 +270,8 @@ extension SPStorkPresentationController {
|
||||
self.workGester = true
|
||||
self.indicatorView.style = .line
|
||||
self.presentingViewController.view.layer.removeAllAnimations()
|
||||
self.presentingViewController.view.endEditing(true)
|
||||
self.presentedViewController.view.endEditing(true)
|
||||
gestureRecognizer.setTranslation(CGPoint(x: 0, y: 0), in: containerView)
|
||||
case .changed:
|
||||
self.workGester = true
|
||||
|
||||
+2
@@ -26,6 +26,7 @@ public final class SPStorkTransitioningDelegate: NSObject, UIViewControllerTrans
|
||||
public var isSwipeToDismissEnabled: Bool = true
|
||||
public var isTapAroundToDismissEnabled: Bool = true
|
||||
public var showIndicator: Bool = true
|
||||
public var indicatorColor: UIColor = UIColor.init(red: 202/255, green: 201/255, blue: 207/255, alpha: 1)
|
||||
public var customHeight: CGFloat? = nil
|
||||
|
||||
public func presentationController(forPresented presented: UIViewController, presenting: UIViewController?, source: UIViewController) -> UIPresentationController? {
|
||||
@@ -33,6 +34,7 @@ public final class SPStorkTransitioningDelegate: NSObject, UIViewControllerTrans
|
||||
controller.isSwipeToDismissEnabled = self.isSwipeToDismissEnabled
|
||||
controller.isTapAroundToDismissEnabled = self.isTapAroundToDismissEnabled
|
||||
controller.showIndicator = self.showIndicator
|
||||
controller.indicatorColor = self.indicatorColor
|
||||
controller.customHeight = self.customHeight
|
||||
controller.transitioningDelegate = self
|
||||
return controller
|
||||
|
||||
@@ -21,7 +21,4 @@
|
||||
|
||||
import UIKit
|
||||
|
||||
struct SPCodeDraw {
|
||||
|
||||
private init() {}
|
||||
}
|
||||
struct SPCodeDraw { private init() {} }
|
||||
|
||||
+974
-107
File diff suppressed because it is too large
Load Diff
+10
-10
@@ -24,11 +24,11 @@ import Photos
|
||||
|
||||
extension UIViewController {
|
||||
|
||||
func present(_ viewControllerToPresent: UIViewController, completion: (() -> Swift.Void)? = nil) {
|
||||
public func present(_ viewControllerToPresent: UIViewController, completion: (() -> Swift.Void)? = nil) {
|
||||
self.present(viewControllerToPresent, animated: true, completion: completion)
|
||||
}
|
||||
|
||||
@objc func dismiss() {
|
||||
@objc public func dismiss() {
|
||||
self.dismiss(animated: true, completion: nil)
|
||||
}
|
||||
|
||||
@@ -41,20 +41,20 @@ extension UIViewController {
|
||||
|
||||
extension UIViewController {
|
||||
|
||||
func dismissKeyboardWhenTappedAround() {
|
||||
public func dismissKeyboardWhenTappedAround() {
|
||||
let tap: UITapGestureRecognizer = UITapGestureRecognizer(target: self, action: #selector(UIViewController.dismissKeyboard))
|
||||
tap.cancelsTouchesInView = false
|
||||
view.addGestureRecognizer(tap)
|
||||
}
|
||||
|
||||
@objc func dismissKeyboard() {
|
||||
@objc public func dismissKeyboard() {
|
||||
view.endEditing(true)
|
||||
}
|
||||
}
|
||||
|
||||
extension UIViewController {
|
||||
|
||||
func save(image: UIImage) {
|
||||
public func save(image: UIImage) {
|
||||
if PHPhotoLibrary.authorizationStatus() == PHAuthorizationStatus.authorized {
|
||||
UIImageWriteToSavedPhotosAlbum(image, self, #selector(self.image(_:didFinishSavingWithError:contextInfo:)), nil)
|
||||
} else {
|
||||
@@ -62,7 +62,7 @@ extension UIViewController {
|
||||
}
|
||||
}
|
||||
|
||||
func saveVideo(url: String, complection: @escaping (Bool)->()) {
|
||||
public func saveVideo(url: String, complection: @escaping (Bool)->()) {
|
||||
DispatchQueue.global(qos: .utility).async {
|
||||
let urls = URL(string: url)
|
||||
let urldata = try? Data(contentsOf: urls!)
|
||||
@@ -141,7 +141,7 @@ extension UIViewController {
|
||||
|
||||
extension UIViewController {
|
||||
|
||||
var safeArea: UIEdgeInsets {
|
||||
public var safeArea: UIEdgeInsets {
|
||||
if #available(iOS 11.0, *) {
|
||||
return self.view.safeAreaInsets
|
||||
} else {
|
||||
@@ -149,18 +149,18 @@ extension UIViewController {
|
||||
}
|
||||
}
|
||||
|
||||
var navigationBarHeight: CGFloat {
|
||||
public var navigationBarHeight: CGFloat {
|
||||
return self.navigationController?.navigationBar.frame.height ?? 0
|
||||
}
|
||||
|
||||
static var statusBarHeight: CGFloat {
|
||||
public static var statusBarHeight: CGFloat {
|
||||
return UIApplication.shared.statusBarFrame.height
|
||||
}
|
||||
}
|
||||
|
||||
extension UIViewController {
|
||||
|
||||
var navigationTitleColor: UIColor? {
|
||||
public var navigationTitleColor: UIColor? {
|
||||
get {
|
||||
return (self.navigationController?.navigationBar.titleTextAttributes?[NSAttributedString.Key.foregroundColor] as? UIColor) ?? nil
|
||||
}
|
||||
|
||||
+4
@@ -103,6 +103,9 @@ class SPGolubevIconView: UIView {
|
||||
case .headphones:
|
||||
SPCodeDraw.GolubevIconPack.drawHeadphones(frame: rect, resizing: .aspectFit, white: self.whiteColor, light: self.lightColor, medium: self.mediumColor, dark: self.darkColor)
|
||||
break
|
||||
case .windmill:
|
||||
SPCodeDraw.GolubevIconPack.drawWindmill(frame: rect, resizing: .aspectFit, white: self.whiteColor, light: self.lightColor, medium: self.mediumColor, dark: self.darkColor)
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
@@ -116,6 +119,7 @@ class SPGolubevIconView: UIView {
|
||||
case documents
|
||||
case compass
|
||||
case headphones
|
||||
case windmill
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -86,8 +86,8 @@ class SPMengTransformCollectionViewCell: SPCollectionViewCell {
|
||||
self.backgroundImageView.bottomAnchor.constraint(equalTo:
|
||||
contentView.bottomAnchor, constant: 0).isActive = true
|
||||
|
||||
self.gradientView.startColorPosition = .TopLeft
|
||||
self.gradientView.endColorPosition = .BottomRight
|
||||
self.gradientView.startColorPosition = .topLeft
|
||||
self.gradientView.endColorPosition = .bottomRight
|
||||
self.gradientView.isHidden = true
|
||||
self.gradientView.translatesAutoresizingMaskIntoConstraints = false
|
||||
self.gradientView.layer.masksToBounds = false
|
||||
|
||||
+7
-4
@@ -23,9 +23,9 @@ import UIKit
|
||||
|
||||
class SPSectionLabelsView: SPView {
|
||||
|
||||
let titleLabel = UILabel()
|
||||
let subtitleLabel = UILabel()
|
||||
let button = UIButton.init(type: UIButton.ButtonType.system)
|
||||
let titleLabel = SPLabel()
|
||||
let subtitleLabel = SPLabel()
|
||||
let button = SPButton()
|
||||
|
||||
override func commonInit() {
|
||||
super.commonInit()
|
||||
@@ -59,15 +59,18 @@ class SPSectionLabelsView: SPView {
|
||||
self.titleLabel.sizeToFit()
|
||||
self.titleLabel.setWidth(self.frame.width)
|
||||
self.titleLabel.frame.origin = CGPoint.zero
|
||||
//self.titleLabel.backgroundColor = UIColor.lightGray
|
||||
|
||||
self.subtitleLabel.sizeToFit()
|
||||
self.subtitleLabel.setWidth(self.frame.width)
|
||||
self.subtitleLabel.frame.origin.x = 0
|
||||
self.subtitleLabel.frame.origin.y = self.titleLabel.frame.bottomYPosition + 3
|
||||
//self.subtitleLabel.backgroundColor = UIColor.darkGray
|
||||
|
||||
self.button.sizeToFit()
|
||||
self.button.frame.bottomXPosition = self.frame.width
|
||||
self.button.frame.bottomYPosition = self.titleLabel.frame.bottomYPosition
|
||||
self.button.center.y = self.titleLabel.center.y
|
||||
//self.button.backgroundColor = UIColor.darkGray
|
||||
|
||||
self.setHeight(self.subtitleLabel.frame.bottomYPosition)
|
||||
}
|
||||
|
||||
@@ -25,10 +25,10 @@ public class SPGradientView: SPView {
|
||||
|
||||
var gradientLayer: CAGradientLayer = CAGradientLayer()
|
||||
|
||||
var startColor: UIColor = UIColor.white { didSet { self.updateGradient() }}
|
||||
var endColor: UIColor = UIColor.black { didSet { self.updateGradient() }}
|
||||
var startColorPosition: Position = Position.TopLeft { didSet { self.updateGradient() }}
|
||||
var endColorPosition: Position = Position.BottomRight { didSet { self.updateGradient() }}
|
||||
var startColor = UIColor.white { didSet { self.updateGradient() }}
|
||||
var endColor = UIColor.black { didSet { self.updateGradient() }}
|
||||
var startColorPosition = Position.topLeft { didSet { self.updateGradient() }}
|
||||
var endColorPosition = Position.bottomRight { didSet { self.updateGradient() }}
|
||||
|
||||
override func commonInit() {
|
||||
super.commonInit()
|
||||
@@ -48,32 +48,33 @@ public class SPGradientView: SPView {
|
||||
}
|
||||
|
||||
public enum Position {
|
||||
case TopLeft
|
||||
case TopCenter
|
||||
case TopRight
|
||||
case BottomLeft
|
||||
case BottomCenter
|
||||
case BottomRight
|
||||
case MediumLeft
|
||||
case MediumRight
|
||||
|
||||
case topLeft
|
||||
case topCenter
|
||||
case topRight
|
||||
case bottomLeft
|
||||
case bottomCenter
|
||||
case bottomRight
|
||||
case mediumLeft
|
||||
case mediumRight
|
||||
|
||||
var point: CGPoint {
|
||||
switch self {
|
||||
case .TopLeft:
|
||||
case .topLeft:
|
||||
return CGPoint.init(x: 0, y: 0)
|
||||
case .TopCenter:
|
||||
case .topCenter:
|
||||
return CGPoint.init(x: 0.5, y: 0)
|
||||
case .TopRight:
|
||||
case .topRight:
|
||||
return CGPoint.init(x: 1, y: 0)
|
||||
case .BottomLeft:
|
||||
case .bottomLeft:
|
||||
return CGPoint.init(x: 0, y: 1)
|
||||
case .BottomCenter:
|
||||
case .bottomCenter:
|
||||
return CGPoint.init(x: 0.5, y: 1)
|
||||
case .BottomRight:
|
||||
case .bottomRight:
|
||||
return CGPoint.init(x: 1, y: 1)
|
||||
case .MediumLeft:
|
||||
case .mediumLeft:
|
||||
return CGPoint.init(x: 0, y: 0.5)
|
||||
case .MediumRight:
|
||||
case .mediumRight:
|
||||
return CGPoint.init(x: 1, y: 0.5)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,14 +29,14 @@ class SPSeparatorView: SPView {
|
||||
|
||||
override func commonInit() {
|
||||
super.commonInit()
|
||||
self.backgroundColor = UIColor.init(hex: "515B66").withAlphaComponent(0.4)
|
||||
self.backgroundColor = UIColor.init(hex: "515B66").withAlphaComponent(0.25)
|
||||
self.round = true
|
||||
self.setHeight(self.height)
|
||||
}
|
||||
|
||||
func layout(origin: CGPoint, width: CGFloat) {
|
||||
self.frame.origin = origin
|
||||
self.set(width: width, height: self.height)
|
||||
self.frame.origin = CGPoint.init(x: floor(origin.x), y: floor(origin.y))
|
||||
self.set(width: floor(width), height: self.height)
|
||||
}
|
||||
|
||||
override func layoutSubviews() {
|
||||
|
||||
@@ -6,7 +6,7 @@ Preview GIF is loading `3mb`. Please, wait.
|
||||
|
||||
<img src="https://github.com/IvanVorobei/SPStorkController/blob/master/Resources/Preview.gif" width="500">
|
||||
|
||||
You can download example [from AppStore](https://itunes.apple.com/app/id1446635818). If you want to buy source code of the app shown on the GIF above, please go to [xcode-shop.com](https://xcode-shop.com). Price: $200.
|
||||
You can download example [from AppStore](https://itunes.apple.com/app/id1446635818). Also in the app you can donate me a cup of coffee. If you want to buy source code of the app shown on the GIF above, please go to [xcode-shop.com](https://xcode-shop.com). Price: $200.
|
||||
|
||||
<img src="https://github.com/IvanVorobei/SPStorkController/blob/master/Resources/Shop.svg"/>
|
||||
|
||||
@@ -26,7 +26,8 @@ pod 'SPStorkController'
|
||||
```
|
||||
|
||||
## How to use
|
||||
Create controller and set `transitioningDelegate` to `SPStorkTransitioningDelegate` object. Use `present` or `dismiss` functions:
|
||||
|
||||
Create controller and call func `presentAsStork`:
|
||||
|
||||
```swift
|
||||
import UIKit
|
||||
@@ -38,14 +39,21 @@ class ViewController: UIViewController {
|
||||
super.viewDidAppear(animated)
|
||||
|
||||
let controller = UIViewController()
|
||||
let transitionDelegate = SPStorkTransitioningDelegate()
|
||||
controller.transitioningDelegate = transitionDelegate
|
||||
controller.modalPresentationStyle = .custom
|
||||
self.present(controller, animated: true, completion: nil)
|
||||
self.presentAsStork(controller)
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
If you want customize controller (remove indicator, set custom height and other), create controller and set `transitioningDelegate` to `SPStorkTransitioningDelegate` object. Use `present` or `dismiss` functions:
|
||||
|
||||
```swift
|
||||
let controller = UIViewController()
|
||||
let transitionDelegate = SPStorkTransitioningDelegate()
|
||||
controller.transitioningDelegate = transitionDelegate
|
||||
controller.modalPresentationStyle = .custom
|
||||
self.present(controller, animated: true, completion: nil)
|
||||
```
|
||||
|
||||
Please, do not init `SPStorkTransitioningDelegate` like this:
|
||||
|
||||
```swift
|
||||
@@ -101,6 +109,11 @@ transitionDelegate.isTapAroundToDismissEnabled = true
|
||||
transitionDelegate.showIndicator = true
|
||||
```
|
||||
|
||||
- Parameter `indicatorColor` for customize color of arrow. Default is `gray`:
|
||||
```swift
|
||||
transitionDelegate.indicatorColor = UIColor.white
|
||||
```
|
||||
|
||||
- Parameter `customHeight` sets custom height for modal controller. Default is `nil`:
|
||||
```swift
|
||||
transitionDelegate.customHeight = 350
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
Pod::Spec.new do |s|
|
||||
s.name = "SPStorkController"
|
||||
s.version = "1.2.1"
|
||||
s.version = "1.2.6"
|
||||
s.summary = "Modal controller as mail or Apple music application"
|
||||
s.homepage = "https://github.com/IvanVorobei/SPStorkController"
|
||||
s.source = { :git => "https://github.com/IvanVorobei/SPStorkController.git", :tag => s.version }
|
||||
|
||||
@@ -63,12 +63,3 @@ public struct SPStorkController {
|
||||
|
||||
private init() {}
|
||||
}
|
||||
|
||||
extension UIViewController {
|
||||
|
||||
var isPresentedAsStork: Bool {
|
||||
return transitioningDelegate is SPStorkTransitioningDelegate
|
||||
&& modalPresentationStyle == .custom
|
||||
&& presentingViewController != nil
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,6 +42,13 @@ class SPStorkIndicatorView: UIView {
|
||||
}
|
||||
}
|
||||
|
||||
var color: UIColor = UIColor.init(red: 202/255, green: 201/255, blue: 207/255, alpha: 1) {
|
||||
didSet {
|
||||
self.leftView.backgroundColor = self.color
|
||||
self.rightView.backgroundColor = self.color
|
||||
}
|
||||
}
|
||||
|
||||
private var leftView: UIView = UIView()
|
||||
private var rightView: UIView = UIView()
|
||||
|
||||
@@ -50,8 +57,7 @@ class SPStorkIndicatorView: UIView {
|
||||
self.backgroundColor = UIColor.clear
|
||||
self.addSubview(self.leftView)
|
||||
self.addSubview(self.rightView)
|
||||
self.leftView.backgroundColor = UIColor.init(red: 202/255, green: 201/255, blue: 207/255, alpha: 1)
|
||||
self.rightView.backgroundColor = UIColor.init(red: 202/255, green: 201/255, blue: 207/255, alpha: 1)
|
||||
self.color = UIColor.init(red: 202/255, green: 201/255, blue: 207/255, alpha: 1)
|
||||
}
|
||||
|
||||
required init?(coder aDecoder: NSCoder) {
|
||||
|
||||
@@ -26,6 +26,7 @@ class SPStorkPresentationController: UIPresentationController, UIGestureRecogniz
|
||||
var isSwipeToDismissEnabled: Bool = true
|
||||
var isTapAroundToDismissEnabled: Bool = true
|
||||
var showIndicator: Bool = true
|
||||
var indicatorColor: UIColor = UIColor.init(red: 202/255, green: 201/255, blue: 207/255, alpha: 1)
|
||||
var customHeight: CGFloat? = nil
|
||||
var transitioningDelegate: SPStorkTransitioningDelegate?
|
||||
|
||||
@@ -82,6 +83,7 @@ class SPStorkPresentationController: UIPresentationController, UIGestureRecogniz
|
||||
guard let containerView = self.containerView, let presentedView = self.presentedView, let window = containerView.window else { return }
|
||||
|
||||
if self.showIndicator {
|
||||
self.indicatorView.color = self.indicatorColor
|
||||
presentedView.addSubview(self.indicatorView)
|
||||
}
|
||||
self.updateLayoutIndicator()
|
||||
@@ -268,6 +270,8 @@ extension SPStorkPresentationController {
|
||||
self.workGester = true
|
||||
self.indicatorView.style = .line
|
||||
self.presentingViewController.view.layer.removeAllAnimations()
|
||||
self.presentingViewController.view.endEditing(true)
|
||||
self.presentedViewController.view.endEditing(true)
|
||||
gestureRecognizer.setTranslation(CGPoint(x: 0, y: 0), in: containerView)
|
||||
case .changed:
|
||||
self.workGester = true
|
||||
|
||||
@@ -26,6 +26,7 @@ public final class SPStorkTransitioningDelegate: NSObject, UIViewControllerTrans
|
||||
public var isSwipeToDismissEnabled: Bool = true
|
||||
public var isTapAroundToDismissEnabled: Bool = true
|
||||
public var showIndicator: Bool = true
|
||||
public var indicatorColor: UIColor = UIColor.init(red: 202/255, green: 201/255, blue: 207/255, alpha: 1)
|
||||
public var customHeight: CGFloat? = nil
|
||||
|
||||
public func presentationController(forPresented presented: UIViewController, presenting: UIViewController?, source: UIViewController) -> UIPresentationController? {
|
||||
@@ -33,6 +34,7 @@ public final class SPStorkTransitioningDelegate: NSObject, UIViewControllerTrans
|
||||
controller.isSwipeToDismissEnabled = self.isSwipeToDismissEnabled
|
||||
controller.isTapAroundToDismissEnabled = self.isTapAroundToDismissEnabled
|
||||
controller.showIndicator = self.showIndicator
|
||||
controller.indicatorColor = self.indicatorColor
|
||||
controller.customHeight = self.customHeight
|
||||
controller.transitioningDelegate = self
|
||||
return controller
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
// The MIT License (MIT)
|
||||
// Copyright © 2017 Ivan Vorobei (hello@ivanvorobei.by)
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
import UIKit
|
||||
|
||||
extension UIViewController {
|
||||
|
||||
public var isPresentedAsStork: Bool {
|
||||
return transitioningDelegate is SPStorkTransitioningDelegate
|
||||
&& modalPresentationStyle == .custom
|
||||
&& presentingViewController != nil
|
||||
}
|
||||
|
||||
public func presentAsStork(_ controller: UIViewController, complection: (() -> Void)? = nil) {
|
||||
let transitionDelegate = SPStorkTransitioningDelegate()
|
||||
controller.transitioningDelegate = transitionDelegate
|
||||
controller.modalPresentationStyle = .custom
|
||||
self.present(controller, animated: true, completion: complection)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user