123456789101112131415161718192021222324252627282930313233343536 |
- //
- // UIViewController+Presentation.swift
- // Inhealth
- //
- // Created by weclouds on 2020/1/7.
- // Copyright © 2020 weclouds. All rights reserved.
- //
- import UIKit
- fileprivate struct AssociatedKeys {
- fileprivate static var controllerHeightKey :String = "controllerHeight"
-
- }
- extension UIViewController:UIViewControllerTransitioningDelegate{
- var controllerHeight : CGFloat?{
- set{
- objc_setAssociatedObject(self, &AssociatedKeys.controllerHeightKey, newValue, .OBJC_ASSOCIATION_ASSIGN)
- }
- get{
- return objc_getAssociatedObject(self, &AssociatedKeys.controllerHeightKey) as? CGFloat
- }
- }
- func modal(_ vc:UIViewController,controllerHeight:CGFloat) {
-
- vc.modalPresentationStyle = .custom
- vc.controllerHeight = controllerHeight
-
- vc.transitioningDelegate = self
- self.present(vc, animated: true, completion: nil)
- }
- public func presentationController(forPresented presented: UIViewController, presenting: UIViewController?, source: UIViewController) -> UIPresentationController? {
- return IHPresentBottom(presentedViewController: presented, presenting: presenting)
- }
-
- }
|