Sometimes you want to make a subview have rounded corners. An easy way to do this is:
v.backgroundColor = bgColor
v.layer.cornerRadius = 7
v.layer.masksToBounds = true
This works well most of the time, but you run into performance degradation when you render more complex subviews with rounded corners, e.g many UILabel
s with rounded corners in a UITableView
with many cells.
An easy way around this issue is to switch of masksToBounds
and set the background on the layer instead of the view:
v.layer.backgroundColor = bgColor.cgColor
v.layer.cornerRadius = 7
Your feedback is valuable: Do you want more nuggets like this? Yes or No
.
.