Created
June 5, 2020 13:58
-
-
Save PimCoumans/7365b2d700433fa25d434edbba948f3b to your computer and use it in GitHub Desktop.
Simple UIView rounded corners with iOS 13’s continuous corners
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import UIKit | |
extension CACornerMask { | |
static let all: CACornerMask = [ | |
.layerMaxXMaxYCorner, .layerMaxXMinYCorner, .layerMinXMaxYCorner, .layerMinXMinYCorner | |
] | |
} | |
extension UIView { | |
func roundCorners(by radius: CGFloat, corners: CACornerMask = .all) { | |
layer.cornerRadius = radius | |
layer.maskedCorners = corners | |
if #available(iOS 13.0, *) { | |
layer.cornerCurve = .continuous | |
} | |
layer.masksToBounds = true | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment