Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| e37c43c8f3 | |||
| 001536c835 |
@@ -51,6 +51,7 @@ let controller = UIViewController()
|
||||
let transitionDelegate = SPStorkTransitioningDelegate()
|
||||
controller.transitioningDelegate = transitionDelegate
|
||||
controller.modalPresentationStyle = .custom
|
||||
controller.modalPresentationCapturesStatusBarAppearance = true
|
||||
self.present(controller, animated: true, completion: nil)
|
||||
```
|
||||
|
||||
@@ -82,22 +83,27 @@ class ModalViewController: UIViewController {
|
||||
override var preferredStatusBarStyle: UIStatusBarStyle {
|
||||
return .lightContent
|
||||
}
|
||||
|
||||
override func viewDidLoad() {
|
||||
super.viewDidLoad()
|
||||
self.modalPresentationCapturesStatusBarAppearance = true
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Parameters
|
||||
|
||||
- Parameter `customHeight` sets custom height for modal controller. Default is `nil`:
|
||||
```swift
|
||||
transitionDelegate.customHeight = 350
|
||||
```
|
||||
|
||||
- Parameter `swipeToDismissEnabled` enables dismissal by swipe gesture. Default is `true`:
|
||||
|
||||
```swift
|
||||
transitionDelegate.swipeToDismissEnabled = true
|
||||
```
|
||||
|
||||
- Parameter `translateForDismiss` sets how much need to swipe down to close the controller. Work only if `swipeToDismissEnabled` is true. Default is `240`:
|
||||
```swift
|
||||
transitionDelegate.translateForDismiss = 100
|
||||
```
|
||||
|
||||
- Parameter `tapAroundToDismissEnabled` enables dismissal by tapping parent controller. Default is `true`:
|
||||
|
||||
```swift
|
||||
@@ -114,16 +120,6 @@ transitionDelegate.showIndicator = true
|
||||
transitionDelegate.indicatorColor = UIColor.white
|
||||
```
|
||||
|
||||
- Parameter `customHeight` sets custom height for modal controller. Default is `nil`:
|
||||
```swift
|
||||
transitionDelegate.customHeight = 350
|
||||
```
|
||||
|
||||
- Parameter `translateForDismiss` sets how much need to swipe down to close the controller. Work only if `swipeToDismissEnabled` is true. Default is `240`:
|
||||
```swift
|
||||
transitionDelegate.translateForDismiss = 100
|
||||
```
|
||||
|
||||
### Snapshots
|
||||
|
||||
The project uses a snapshot of the screen in order to avoid compatibility and customization issues. Before controller presentation, a snapshot of the parent view is made, and size and position are changed for the snapshot. Sometimes you will need to update the screenshot of the parent view, for that use static func:
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
Pod::Spec.new do |s|
|
||||
s.name = "SPStorkController"
|
||||
s.version = "1.4.2"
|
||||
s.version = "1.4.4"
|
||||
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 }
|
||||
|
||||
@@ -187,6 +187,8 @@ class SPStorkPresentationController: UIPresentationController, UIGestureRecogniz
|
||||
}
|
||||
|
||||
@objc func dismissAction() {
|
||||
self.presentingViewController.view.endEditing(true)
|
||||
self.presentedViewController.view.endEditing(true)
|
||||
self.presentedViewController.dismiss(animated: true, completion: nil)
|
||||
}
|
||||
|
||||
|
||||
@@ -31,10 +31,16 @@ final class SPStorkPresentingAnimationController: NSObject, UIViewControllerAnim
|
||||
|
||||
let containerView = transitionContext.containerView
|
||||
containerView.addSubview(presentedViewController.view)
|
||||
presentedViewController.view.frame = CGRect(x: 0, y: containerView.bounds.height, width: containerView.bounds.width, height: containerView.bounds.height)
|
||||
|
||||
//presentedViewController.view.frame = CGRect(x: 0, y: containerView.bounds.height, width: containerView.bounds.width, height: containerView.bounds.height)
|
||||
|
||||
let finalFrameForPresentedView = transitionContext.finalFrame(for: presentedViewController)
|
||||
|
||||
// NEW FRAMING: Testing now. Maybe correct. If remove it lines, init frame of controller will be equal container (not stork)
|
||||
presentedViewController.view.frame = finalFrameForPresentedView
|
||||
presentedViewController.view.frame.origin.y = containerView.bounds.height
|
||||
// END NEW.
|
||||
|
||||
UIView.animate(
|
||||
withDuration: transitionDuration(using: transitionContext),
|
||||
delay: 0,
|
||||
|
||||
@@ -29,10 +29,12 @@ extension UIViewController {
|
||||
&& presentingViewController != nil
|
||||
}
|
||||
|
||||
public func presentAsStork(_ controller: UIViewController, complection: (() -> Void)? = nil) {
|
||||
public func presentAsStork(_ controller: UIViewController, height: CGFloat? = nil, complection: (() -> Void)? = nil) {
|
||||
let transitionDelegate = SPStorkTransitioningDelegate()
|
||||
transitionDelegate.customHeight = height
|
||||
controller.transitioningDelegate = transitionDelegate
|
||||
controller.modalPresentationStyle = .custom
|
||||
controller.modalPresentationCapturesStatusBarAppearance = true
|
||||
self.present(controller, animated: true, completion: complection)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user