我试图创建一个模糊的登录屏幕,我查找了如何在线进行操作。当我将约束应用于图像视图时(根据我的理解/思考),它不适用于模糊的部分。
import UIKit
class ViewController: UIViewController {
@IBOutlet var mainBackgroundImage: UIImageView!
override func viewDidLoad() {
self.view.layoutIfNeeded()
self.blurMainImg()
super.viewDidLoad()
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
func blurMainImg(){
let blurEffect = UIBlurEffect(style: UIBlurEffectStyle.Dark)
let blurView = UIVisualEffectView(effect: blurEffect)
blurView.frame = mainBackgroundImage.bounds
mainBackgroundImage.addSubview(blurView)
}
}