Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Corner radius on UIVisualEffectView

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.

like image 978
Johan Enstam Avatar asked Mar 13 '15 09:03

Johan Enstam


People also ask

How do you add corner radius to a label?

"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..

How do you corner radius in a storyboard?

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)

How do you round the corners of a view?

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 .

How do you give shadow to corner radius of view in Swift?

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.


1 Answers

After @theMonster suggestion, I am posting what was a comment.

override func viewDidLoad() {     super.viewDidLoad()     blurView.layer.cornerRadius = 50     blurView.clipsToBounds = true } 
like image 196
Mike M Avatar answered Oct 14 '22 20:10

Mike M