I am working with swift UIVisualEffectView with mask option.
I am trying to make a blurred UIVisualEffectView masked by UIImageView.
I've set autolayout constraints to the views at the storyboard but the result varies through the iOS device.
Storyboard, code and results are attached below.
I would be glad if anyone help me.
I've set all auto layout constraints at the storyboard.(Capture included below)
Code is very simple. I've only set blurView.mask = topImageView.
class TestViewController: UIViewController {
@IBOutlet weak var bottomImageView: UIImageView!
@IBOutlet weak var topImageView: UIImageView!
@IBOutlet weak var blurView: UIVisualEffectView!
override func viewDidLoad() {
super.viewDidLoad()
blurView.mask = topImageView
}
// Still same issue when I move the mask to 'viewDidLayoutSubviews()' method
//
// override func viewDidLayoutSubviews() {
// super.viewDidLoad()
// blurView.mask = topImageView
// }
}
Results depending on iOS versions
---
I've tried to move mask code from viewDidLoad() method to viewDidLayoutSubviews() but it's still same.
Self-solved by the below code. Received a hint from similar issue : 'https://stackoverflow.com/questions/58998541/swift-mask-uiview-constraints-issues/59037761'