I'm trying to create a blurry login screen and I looked up how to do it online. When I apply the constraints to the image view, (from what I understand/think) it doesnt apply to the blurred out part.
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)
}
}
As you have post in your picture seems it's a matter of constraints (leading and trailing) you must delete it and put trailing constraint to Superview = 0, the same for leading -> Superview = 0
An example (look for trailing and leading):
P.S.: dont forgot to silent warning by update your constraints (tap the yellow triangle and flag for all)