FileUtils.cp_r('Pods/Target Support Files/Pods-WhatsOpen/Pods-WhatsOpen-Acknowledgements.plist','WhatsOpen/Settings.bundle/Acknowledgements.plist',:remove_destination=>true)
@@ -25,7 +25,7 @@ Hereʼs a GIF showing it in action.
To install DeckTransition using [CocoaPods](http://cocoapods.org), add the following line to your Podfile:
```
pod 'DeckTransition', '~> 1.0'
pod 'DeckTransition', '~> 2.0'
```
### Carthage
...
...
@@ -33,7 +33,7 @@ pod 'DeckTransition', '~> 1.0'
To install DeckTransition using [Carthage](https://github.com/Carthage/Carthage), add the following line to your Cartfile:
```
github "HarshilShah/DeckTransition" ~> 1.0
github "HarshilShah/DeckTransition" ~> 2.0
```
## Documentation
...
...
@@ -46,7 +46,7 @@ You can find [the docs here](https://harshilshah.github.io/DeckTransition "Docum
Set `modalPresentationCapturesStatusBarAppearance` to `true` in your modal view controller, and override the `preferredStatusBarStyle` variable to return `.lightContent`.
The background color for the presentation can be changed by changing the `backgroundColor`property of the `window`. This is `.black` by default.
Additionally, the `UIScrollView` instances which should be tracked for the swipe-to-dismiss gesture should have their`backgroundColor`set to `.clear`.
This is the part where it gets a bit tricky. If youʼve got a fixed-sized i.e. non-scrolling modal, feel free to just skip the rest of this section. Swipe-to-dismiss will work perfectly for you
By default, DeckTransition has a swipe-to-dismiss gesture which is automatically enabled when your modalʼs main `UIScrollView` is scrolled to the top.
For modals which have a vertically scrolling layout, the dismissal gesture should be fired only when the view is scrolled to the top. To achieve this behaviour, you need to modify the `isDismissEnabled` property of the `DeckTransitioningDelegate`. (You can also set `isDismissEnabled` to false if you want to disable the swipe-to-dismiss UI.)
You can opt-out of this behaviour by passing in `false` for the `isSwipeToDismissEnabled` parameter while initialising your `DeckTransitioningDelegate`.
The one issue with doing this in response to the scrollviewʼs `contentOffset` is momentum scrolling. When the user pans from top the bottom, once the top of the scrollview is reached (`contentOffset.y` is 0), the dismiss gesture should take over and the scrollview should stop scrolling, not showing the usual iOS bounce effect. The dismiss gesture, however, only responds to pans and not swipes, so should you swipe and not pan, the scrollview will scroll to the top and abruptly stop (as the `contentOffset.y` is 0) without the usual iOS bounce effect.
### `UIScrollView` detection
I've found a temporary workaround for this, the code for this can be found below. Itʼs a bit messy right now, but is the only workaround Iʼve found for this issue (so far). It has one caveat, in that it fails utterly miserably when using with a scrollview whose `backgroundColor` isnʼt `.clear`.
Iʼll update this project if/when I find a better solution.
DeckTransition has an internal heuristic to determine which `UIScrollView` should be tracked for the swipe-to-dismiss gesture. In general, this should be sufficient for and cover most use cases.
#### Dismissal code for scrolling modals
First up, make your modal view controller conform to `UIScrollViewDelegate` (or `UITableViewDelegate`/`UITextFieldDelegate`, as the case may be), and assign self as the scrollview's `delegate`.
Next, add this method to your modal view controller, swapping in your scrollviewʼs variable for `textView`.
// If the user has panned to the top, the scrollview doesnʼt bounce and
// the dismiss gesture is enabled.
scrollView.bounces=false
delegate.isDismissEnabled=true
}
}
}
}
```
However there are some edge cases, and should you run into one, these can we worked around by making your modal view controller conform to the `DeckTransitionViewControllerProtocol` protocol. More information about this can be found in the documentation page about [UIScrollView detection](https://harshilshah.github.io/DeckTransition/uiscrollview-detection.html).