https://github.com/qchenqizhi/nonfullscreenpresenter
A lightweight wrapper for easily customizing animation of present non-fullscreen view controller
https://github.com/qchenqizhi/nonfullscreenpresenter
actionsheet alert ios swift transition-animation
Last synced: over 1 year ago
JSON representation
A lightweight wrapper for easily customizing animation of present non-fullscreen view controller
- Host: GitHub
- URL: https://github.com/qchenqizhi/nonfullscreenpresenter
- Owner: qchenqizhi
- License: mit
- Created: 2020-04-21T02:31:13.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2020-04-21T07:08:41.000Z (about 6 years ago)
- Last Synced: 2025-03-02T07:04:09.207Z (over 1 year ago)
- Topics: actionsheet, alert, ios, swift, transition-animation
- Language: Swift
- Homepage:
- Size: 18.6 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# NonfullscreenPresenter
[](https://travis-ci.org/qchenqizhi/NonfullscreenPresenter)
[](https://cocoapods.org/pods/NonfullscreenPresenter)
[](https://cocoapods.org/pods/NonfullscreenPresenter)
[](https://cocoapods.org/pods/NonfullscreenPresenter)
A lightweight wrapper for easily customizing animation of present non-fullscreen view controller
## Features
- [x] Customizing transition animation
- [x] Blured `presentingViewController`
- [x] Tap to dismiss
- [ ] Customizing push & pop
- [ ] Interacting present and dismiss with gesture
## Usage
1. Implement the protocol `NonfullscreenPresented` in `presentedViewController`:
```swift
extension AlertViewController: NonfullscreenPresented {
func presentedFrame(inContainerView view: UIView) -> CGRect {
return view.frame
}
func animation(for transitionType: TransitionType) -> Animation {
let animation = Animation(animations: {
if transitionType == .presentation {
self.contentView.transform = .identity
} else {
self.contentView.alpha = 0
self.contentView.transform = CGAffineTransform(scaleX: 0.1, y: 0.1)
}
})
return animation
}
var backgroundStyle: BackgroundStyle { .blur(.dark) }
var backgroundTapToDismissEnabled: Bool { true }
}
```
2. Then use this function to present in `presentingViewController`:
```swift
self.np.present(alert)
```
## Example
To run the example project, clone the repo, and run `pod install` from the Example directory first.
## Requirements
- Xcode 11.4+
- Swift 5.2+
- iOS 11+
**Lower versions should work too, I just haven’t tried**
## Installation
NonfullscreenPresenter is available through [CocoaPods](https://cocoapods.org). To install
it, simply add the following line to your Podfile:
```ruby
pod 'NonfullscreenPresenter'
```
## Author
Chen Qizhi, qchenqizhi@gmail.com
## License
NonfullscreenPresenter is available under the MIT license. See the LICENSE file for more info.