Skip to content

Instantly share code, notes, and snippets.

@ioslam
Last active September 11, 2021 21:29
Show Gist options
  • Save ioslam/a76e0dab92fec390a39d0432da852e0b to your computer and use it in GitHub Desktop.
Save ioslam/a76e0dab92fec390a39d0432da852e0b to your computer and use it in GitHub Desktop.
CACornerMask Extension
//
// 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