I am setting a background image to a parse login view controller. But also want to add this background How can I achieve this?
Here is the code I am using:
backgroundImage.image = UIImage(named: "Melbourne")
let blurEffect = UIBlurEffect(style: UIBlurEffectStyle.Dark)
let blurEffectView = UIVisualEffectView(effect: blurEffect)
blurEffectView.frame = view.bounds
view.addSubview(blurEffectView)
The problem is that this blurs everything including all the buttons and username and password fields. What can I do?
It is because you are adding your blur view over all the subviews of the view controllers.
try to insert at specific index in view hierarchy.
I have no proper idea of the view hierarchy of your viewController. Do it using try&Error method like below.
try below code.
view.insertSubview(blurEffectView, atIndex: 1);
if not works try by increasing the index value 2 and so on.
view.insertSubview(blurEffectView, atIndex: 2);// if not change it to 3
It will surely works with specific value.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.