我有一个 View Controller (PopOverViewController)被另一个 View Controller (ListViewController)实例化。
在 ListViewController内,PopOverViewController 以模态方式呈现:
popOverVC = self.storyboard?.instantiateViewController(withIdentifier: "sbPopUpID") as! PopUpViewController
popOverVC.modalPresentationStyle = .fullScreen
在 PopOverViewController内,PopOverViewController 通过 CGAfflineTransformation 进行动画输入/输出:
func showAnimate()
{
self.shadowView.transform = CGAffineTransform(scaleX: 0.7, y: 0.7)
self.view.alpha = 0.0;
UIView.animate(withDuration: 0.3, animations: {
self.view.alpha = 1.0
self.shadowView.transform = CGAffineTransform(scaleX: 0.7, y: 0.7)
});
}
func removeAnimate()
{
UIView.animate(withDuration: 0.3, animations: {
self.shadowView.transform = CGAffineTransform(scaleX: 1.0, y: 1.0)
self.view.alpha = 0.0;
}, completion:{(finished: Bool) in
if (finished)
{
self.view.removeFromSuperview()
}
});
}
在PopOverViewController的viewDidLoad中,背景颜色调低:
self.view.backgroundColor = UIColor(white: 0, alpha: 0.7)
我的问题: 当 PopOver 呈现时,由于 PopOver 的 Alpha,背景仍然可见。我想在呈现 PopOver 时模糊此背景,并在关闭 PopOver 时使模糊消失。
我对如何做到这一点感到困惑。
谢谢!
swift 3
最佳答案
private func makeEffectView() {
let effect: UIBlurEffect = UIBlurEffect(style: UIBlurEffectStyle.light)
effectView = UIVisualEffectView(effect: effect)
effectView.frame = CGRect(x:0, y:0, width:UIScreen.main.bounds.size.width, height:UIScreen.main.bounds.size.height)
self.window?.addSubview(effectView)
}
private func removeEffectView() {
if effectView != nil {
self.effectView.removeFromSuperview()
}
}
关于ios - 以编程方式模糊 Pop Over 后面的背景 View ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44425625/