ios 8.0 以前
let vc = UIViewController()
vc.backgroundColor = UIColor(hexString: "#dedede", alpha: 0.5)
vc.modalPresentationStyle = .overCurrentContext
UIApplication.shared.keyWindow?.rootViewController.present(vc, animated: false, completion: nil)
ios8.0以后
let vc = UIViewController()
vc.backgroundColor = UIColor(hexString: "#dedede", alpha: 0.5)
vc.modalPresentationStyle = UIModalPresentationStyle(rawValue: UIModalPresentationStyle.overCurrentContext.rawValue |
UIModalPresentationStyle.fullScreen.rawValue)!
present(vc, animated: false, completion: nil)
注: 如果你添加一个UIControl的视图,请记得放在一个UIView的子视图下。









网友评论