Hi Im wondering if It's possible to set a corner radius on a UIVisualEffectView? Here's the code that i've tried:
@IBOutlet var blurView: UIVisualEffectView! var blurLayer : CALayer{ return blurView.layer } override func viewDidLoad() { super.viewDidLoad() setUpLayer() // Do any additional setup after loading the view. } func setUpLayer(){ blurLayer.cornerRadius = 50 }
and
@IBOutlet var blurView: UIVisualEffectView! override func viewDidLoad() { super.viewDidLoad() blurView.layer.cornerRadius = 50 // Do any additional setup after loading the view. }
Non of them works.
"label. layer. masksToBounds = true" is an important code, if you apply corner radius to a label and if it dosen't work than adding this will definitely add the corner radius to a particular label.. So this should be the correct answer..
Select the view that you want to round and open its Identity Inspector. In the User Defined Runtime Attributes section, add the following two entries: Key Path: layer. cornerRadius , Type: Number, Value: (whatever radius you want)
You can give it round corners by changing the cornerRadius property of the view's layer . and smaller values give less rounded corners. Both clipsToBounds and masksToBounds are equivalent. It is just that the first is used with UIView and the second is used with CALayer .
The Solution I opted to create an inner containerView pinned to the edges of the parent view . The shadow is applied to the parent view 's layer, while the rounded corners are applied to the containerView . Then, just add all content to the containerView and be on your way.
After @theMonster suggestion, I am posting what was a comment.
override func viewDidLoad() { super.viewDidLoad() blurView.layer.cornerRadius = 50 blurView.clipsToBounds = true }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With