I'm using an MWPhotoBrowser instance to show albums or single images in my app. While using a navigation controller, I can simply press the back button to pop the view controller. I wish to present it modally but I can't figure out how to dismiss it. I tried the following code in the hopes that I would be able to swipe down to dismiss, but to no avail.
let browser = MWPhotoBrowser(photos: photos)
browser?.delegate = self
browser?.enableSwipeToDismiss
self.present(browser!, animated: true, completion: nil)
(photos is an array of MWPhoto)
Can anyone point me to a solution? Thanks.
Considering that you can't edit MWPhotoBrowser
. You can approach this problem by adding a floating button after
let windowButton: UIButton = UIButton(type: UIButtonType.custom)
let browser:MWPhotoBrowser? // declared outside functions
self.present(browser, animated: true, completion: {
self.windowButton.frame = CGRect(x: 20, y: 100, width: 50, height: 50)
self.windowButton.backgroundColor = UIColor.brown
self.windowButton.addTarget(self, action: #selector(self.dismissFunc), for: UIControlEvents.touchDown)
if let window:UIWindow = (UIApplication.shared.delegate?.window)! {
window.addSubview(self.windowButton)
}
})
func dismissFunc() {
self.browser.dismiss(animated: true, completion: {
self.windowButton.removeFromSuperview()
})
}