0
我想創建一個模糊和約束的UIImageView。但模糊不想與約束一起工作。UIImageView,約束和模糊編程
我的代碼:
var notifBackground: UIImageView!
notifBackground = UIImageView()
notifBackground.backgroundColor = UIColor.clear
view.addSubview(notifBackground)
notifBackground.translatesAutoresizingMaskIntoConstraints = false
notifBackground.widthAnchor.constraint(equalToConstant: 200).isActive = true
notifBackground.heightAnchor.constraint(equalToConstant: 200).isActive = true
notifBackground.centerXAnchor.constraint(equalTo: view.centerXAnchor).isActive = true
notifBackground.centerYAnchor.constraint(equalTo: view.centerYAnchor).isActive = true
let blur = UIVisualEffectView(effect: UIBlurEffect(style: UIBlurEffectStyle.regular))
blur.frame = notifBackground.bounds
view.addSubview(blur)