This and that of Swift corner Radius

I want to round the specified corner

This time I will touch on UIImage

Described in any file (I created an extension file for UI parts and described it there)

///A method to round a specified corner with a specified radius
///- Parameters: 
///   -radius
///   -Specified corner
 public func setCornerRadius(_ radius: CGFloat,_ corners: CACornerMask) {
    layer.cornerRadius = radius
    layer.masksToBounds = true
    layer.maskedCorners = corners
 }

How to use

///This time, all corners are rounded.
let corners = [.layerMaxXMinYCorner, .layerMinXMaxYCorner, .layerMinXMinYCorner, .layerMaxXMaxYCorner ]
view.setCornerRadius(15, corners)

that's all. I would appreciate it if you could refer to it.

Recommended Posts

This and that of Swift corner Radius
This and that of the JDK
This and that of Core Graphics
This and that of exclusive control
This and that of conditional branching of rails development
Docker settings and this and that
[Rails] strftime this and that
Digital certificate this and that
Base64 encoder this and that
I tried to verify this and that of Spring @ Transactional
[Swift] Advantages and disadvantages of Storyboard
This and that about Base64 (Java)
[Java / Swift] Comparison of Java Interface and Swift Protocol
This and that of the implementation of date judgment within the period in Java
[Rails] Volume that displays favorites and a list of favorites
[Swift] This is the solution! Illustration of Delegate implementation
This and that for editing ini in Java. : inieditor-java
[Swift5] How to analyze complex JSON and get the index of the element that satisfies the condition
[Swift] Constants and variables
List of devices that can be previewed in Swift UI
[Swift] Lightly introduce the logic of the app that passed the selection