About ZFDragableModalTransition
ZFDragableModalTransition is a custom modal transition animation for presenting view controllers.
Features
- Interactive transitions with draggable modal view
- Customize modal view background color, corner radius, and shadow
- Support for both direction-based transition and custom transform-based transition
- Handle gestures and animate dismiss when dragging or swiping
- Control the animation duration and spring damping
Installation
You can install ZFDragableModalTransition via Cocoapods by adding the following line to your Podfile:
pod 'ZFDragableModalTransition'
Usage
To use ZFDragableModalTransition, follow the steps below:
- Import ZFDragableModalTransition module.
- Set the modalPresentationStyle of the view controller to custom before presenting it.
- Assign an instance of ZFDragableModalTransition as the view controller’s transitioningDelegate.
- Adjust the properties of the ZFDragableModalTransition instance according to your needs.
- Call present(_:animated:completion:) method to present the view controller.
Example
import ZFDragableModalTransition
class ViewController: UIViewController {
let transition = ZFDragableModalTransition()
override func viewDidLoad() {
super.viewDidLoad()
// Set the modalPresentationStyle
modalPresentationStyle = .custom
// Assign the transitioningDelegate
transitioningDelegate = transition
}
@IBAction func presentModalViewController() {
let modalViewController = UIStoryboard(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "ModalViewController")
// Customize the modal view properties
// transition.modalBackgroundColor = UIColor.white
// transition.modalCornerRadius = 4.0
// transition.modalShadowOpacity = 0.5
// transition.modalShadowRadius = 6.0
present(modalViewController, animated: true, completion: nil)
}
}
Customization
You can customize the appearance and behavior of the modal view using the following properties:
- modalBackgroundColor: The background color of the modal view.
- modalCornerRadius: The corner radius of the modal view.
- modalShadowOpacity: The opacity of the shadow for the modal view.
- modalShadowRadius: The radius of the shadow for the modal view.
- direction: The direction of the draggable modal view.
- dragableBorderMargin: The margin of the draggable border area.
- animationDuration: The duration of the animation.
- animationDamping: The damping value for the animation.
Conclusion
ZFDragableModalTransition provides a flexible and interactive transition animation for presenting view controllers. It allows you to customize various properties to achieve the desired visual and behavioral effects. With its easy-to-use interface, you can quickly integrate this library into your projects and create a smoother and more engaging user experience.