Search code examples
iosswiftcalayer

Why the edges of UIView are not smooth for huge corner radius?


class AttributedView: UIView {
    private let gradient = CAGradientLayer()
    var cornerRadius: CGFloat = 3 {
        didSet {
            layer.cornerRadius = cornerRadius
        }
    }
}

I simply use it for both: button view (corner radius: 20) and background circle (corner radius: 600).

Why button is smooth, and background is not?

enter image description here

enter image description here


Solution

  • With iOS 13.0 you can simple do, in addition to setting corner radius

    yourView.layer.cornerCurve = .continuous