0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

Swift cornerRadiusのあれこれ

Posted at

#指定の角を丸くしたい#
###今回はUIImageについて触れる###

任意のファイルに記載(わたしはUIパーツのextensionファイルを作成してそこに記載している)

///指定の角を指定の半径で丸くするメソッド
///- Parameters: 
///   - 半径
///   - 指定の角
 public func setCornerRadius(_ radius: CGFloat,_ corners: CACornerMask) {
    layer.cornerRadius = radius
    layer.masksToBounds = true
    layer.maskedCorners = corners
 }

###使い方###

///今回は全ての角に対して丸くする処理を行う。
let corners = [.layerMaxXMinYCorner, .layerMinXMaxYCorner, .layerMinXMinYCorner, .layerMaxXMaxYCorner ]
view.setCornerRadius(15, corners)

以上。参考にしていただけると幸いです。

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?