Last active
September 11, 2021 21:29
-
-
Save ioslam/a76e0dab92fec390a39d0432da852e0b to your computer and use it in GitHub Desktop.
CACornerMask Extension
This file contains hidden or 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
// | |
// CACornerMask+ Ex.swift | |
// | |
// Created by Eslam on 4/10/21. | |
// Copyright © 2021 ioslam. All rights reserved. | |
// | |
// | |
import UIKit | |
extension CACornerMask { | |
/// [.topLeft, .topRight, .BottomLeft, .BottomRight] | |
static var all: CACornerMask { | |
return [.topLeft, .topRight, .bottomLeft, .bottomRight] | |
} | |
/// layerMaxXMinYCorner | |
static var topRight: CACornerMask { | |
return .layerMaxXMinYCorner | |
} | |
/// layerMinXMinYCorner | |
static var topLeft: CACornerMask { | |
return .layerMinXMinYCorner | |
} | |
/// layerMinXMaxYCorner | |
static var bottomLeft: CACornerMask { | |
return .layerMinXMaxYCorner | |
} | |
/// layerMaxXMaxYCorner | |
static var bottomRight: CACornerMask { | |
return .layerMaxXMaxYCorner | |
} | |
/// [.bottomLeft, .bottomRight] | |
static var allBottom: CACornerMask { | |
return [.bottomLeft, .bottomRight] | |
} | |
/// [.topLeft, .topRight] | |
static var allTop: CACornerMask { | |
return [.topLeft, .topRight] | |
} | |
/// [.topRight, .bottomRight] | |
static var allRight: CACornerMask { | |
return [.topRight, .bottomRight] | |
} | |
/// [.bottomLeft, .bottomRight] | |
static var allLeft: CACornerMask { | |
return [.bottomLeft, .bottomRight] | |
} | |
/// all angles but `excluding` | |
static func all(excluding: CACornerMask) -> CACornerMask { | |
switch excluding { | |
case .bottomLeft: return [.topLeft, .topRight, .bottomRight] | |
case .bottomRight: return [.topLeft, .topRight, .bottomLeft] | |
case .topLeft: return [.topRight, .bottomLeft, .bottomRight] | |
case .topRight: return [.topLeft, .bottomLeft, .bottomRight] | |
default: return .all | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment