Custom presentation controller with a dynamic blur background that increases the blur when swiped up and reduces the blur when swiped down to be dismissed with a title like navigation bars and a dismiss button.
video_example.mp4
BlurPopover
is currently available either manually by cloning the project and adding the folder BlurPopover
to your project, or you can use the Swift Package Manager (SPM).
- In Xcode, click File > Swift Packages > Add Package Dependency.
- In the dialog that appears, enter the repository URL: https://github.com/iAmrMohamed/BlurPopover.git
- In Version, select Up to Next Major and take the default option.
- Click Next and select the library
BlurPopover
checkbox, then click Finish and your're all set.
- Requires iOS 13+
It's best to check the examples included in the folder iOS Example.
Select your view controller and choose from the right side panel the identity inspector and set the class to BlurPopoverBaseViewController
(if needed set the module to BlurPopover
too).
import BlurPopover
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
}
@IBAction func presentViewController(_ sender: UIButton) {
let dvc = CustomViewController()
dvc.modalPresentationStyle = .custom
dvc.transitioningDelegate = self
present(dvc, animated: true)
}
}
extension ViewController: UIViewControllerTransitioningDelegate {
func presentationController(forPresented presented: UIViewController, presenting: UIViewController?, source: UIViewController) -> UIPresentationController? {
BlurPopoverPresentationController(presentedViewController: presented, presenting: presenting)
}
}
import BlurPopover
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
}
@IBAction func presentViewController(_ sender: UIButton) {
let dvc = CustomViewController()
present(dvc, animated: true)
}
}
class CustomViewController: BlurPopoverBaseViewController {
override func viewDidLoad() {
super.viewDidLoad()
}
}
import BlurPopover
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
}
@IBAction func presentViewController(_ sender: UIButton) {
let dvc = CustomViewController()
dvc.modalPresentationStyle = .custom
// source will animate from the view when presenting
// destination will animate to the view when dismissing
dvc.transitioningDelegate = BlurPopoverSharedTransitioningDelegate.sharedDelegate(
presentingSourceView: imageView,
dismissingDestinationView: imageView
)
present(dvc, animated: true)
}
}
class CustomViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
}
}
BlurPopover is available under the MIT license. See the LICENSE file for more info.