If you want your UIView to appear as a circle there are couple of ways doing this.
If you don't know the height/width of your view in advance. You can simply override layoutSubviews()
function in it's superview class or func viewDidLayoutSubviews()
function in view controller and set the corner radius directly there.
override func layoutSubviews() {
super.layoutSubviews()
label.layer.cornerRadius = label.frame.size.width/2
}
Don't forget to set the UIView's layer's masksToBounds property to true.
Specify bezier path for the mask layer. Layer's frame must be updated every time the view changes its size.
If you're dealing with images, you can also consider rounding the image itself before displaying it in UIImageView - performance wise it could be a way faster than the previous options.