A lightweight wrapper for easily customizing animation of present non-fullscreen view controller
- Customizing transition animation
- Blured
presentingViewController
- Tap to dismiss
- Customizing push & pop
- Interacting present and dismiss with gesture
-
Implement the protocol
NonfullscreenPresented
inpresentedViewController
: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 } }
-
Then use this function to present in
presentingViewController
:self.np.present(alert)
To run the example project, clone the repo, and run pod install
from the Example directory first.
- Xcode 11.4+
- Swift 5.2+
- iOS 11+
Lower versions should work too, I just haven’t tried
NonfullscreenPresenter is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod 'NonfullscreenPresenter'
Chen Qizhi, [email protected]
NonfullscreenPresenter is available under the MIT license. See the LICENSE file for more info.