Skip to content

Instantly share code, notes, and snippets.

@ochim
Last active June 2, 2020 03:48
Show Gist options
  • Save ochim/92aba6b6c1be17dcbd7a67433394a1f6 to your computer and use it in GitHub Desktop.
Save ochim/92aba6b6c1be17dcbd7a67433394a1f6 to your computer and use it in GitHub Desktop.
[ios]UIViewの角を一部だけ丸くする
  • example
class LineView: UIView {

    override func draw(_ rect: CGRect) {
        layer.cornerRadius = 5
        layer.masksToBounds = true
        // 左側だけ丸くする
        layer.maskedCorners = [.layerMinXMinYCorner, .layerMinXMaxYCorner]
        super.draw(rect)
    }

}
プロパティ 角丸になる場所
layerMinXMinYCorner 左上
layerMaxXMinYCorner 右上
layerMinXMaxYCorner 左下
layerMaxXMaxYCorner 右下
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment