As a result, I created a class called RoundView
class RoundView:UIView { override func layoutSubviews() { super.layoutSubviews() self.layer.cornerRadius = self.bounds.width/2 self.layer.masksToBounds = true } }
And then I apply it to all representations that need to be rounded. So in Storyboard, I add RoundView to Custom Class .
What happened is that if you look inside the storyboard source (XML), each view was the size of the entire screen, you can look inside your own SB code. Therefore, trying to add a corner radius equal to width/2 inside its parent layoutSubviews() element, subview does not have the correct layoutSubviews() . Thus, the radius radius got the value 320/2 instead of 50/2 , which is why he got the deformation.
source share