考虑到您无法编辑MWPhotoBrowser
. 您可以通过在之后添加一个浮动按钮来解决此问题
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()
})
}