Make rounding specific corners easier with extension
Renaming constants goes a long way...
Published: Dec. 13, 2021 Sponsored I want a Press KitI was tired spending time to distinguish between .layerMinXMaxYCorner
and .layerMinXMinYCorner
when trying to round only specific corners with the maskedCorners
property on CALayer
.
So I created simple extension to make this much more pleasant. (At least for me 😃).
import UIKit
extension CACornerMask {
static let bottomLeft = CACornerMask.layerMinXMaxYCorner
static let bottomRight = CACornerMask.layerMaxXMaxYCorner
static let topLeft = CACornerMask.layerMinXMinYCorner
static let topRight = CACornerMask.layerMaxXMinYCorner
}
And then usage:
view.layer.maskedCorners = [.bottomLeft, .bottomRight]
Much more comprehensive to my brain.
Keep in mind, that this is for iOS. On macOS you'll need to modify the definitions, because the Y axis is flipped.