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
/// An extension to provide conversion to and from CIE xyY colors. | |
extension UIColor { | |
/// The CIE xyY components of a color - luminance (Y) and chromaticity (x,y). | |
struct CIExyY: Hashable { | |
/// The x-axis chromaticity coordinate of the color, in the range [0, 1]. | |
var x: CGFloat | |
/// The y-axis chromaticity coordinate of the color, in the range [0, 1]. | |
var y: CGFloat |
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
/// An extension to format strings in *kebab case*. | |
extension String { | |
/// A collection of all the words in the string by separating out any punctuation and spaces. | |
var words: [String] { | |
return components(separatedBy: CharacterSet.alphanumerics.inverted).filter { !$0.isEmpty } | |
} | |
/// Returns a lowercased copy of the string with punctuation removed and spaces replaced | |
/// by a single hyphen, e.g., "the-quick-brown-fox-jumps-over-the-lazy-dog". |
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
/// An extension to format strings in *snake case*. | |
extension String { | |
/// A collection of all the words in the string by separating out any punctuation and spaces. | |
var words: [String] { | |
return components(separatedBy: CharacterSet.alphanumerics.inverted).filter { !$0.isEmpty } | |
} | |
/// Returns a lowercased copy of the string with punctuation removed and spaces replaced | |
/// by a single underscore, e.g., "the_quick_brown_fox_jumps_over_the_lazy_dog". |
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
/// An extension to format strings in *camel case*. | |
extension String { | |
/// A collection of all the words in the string by separating out any punctuation and spaces. | |
var words: [String] { | |
return components(separatedBy: CharacterSet.alphanumerics.inverted).filter { !$0.isEmpty } | |
} | |
/// Returns a copy of the string with the first word beginning lowercased, and the first | |
/// letter of each word thereafter is capitalized, with no intervening spaces or punctuation, |
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
protocol DesignableShadow { | |
var shadowColor: UIColor? { get set } | |
var shadowOffset: CGSize { get set } | |
var shadowRadius: CGFloat { get set } | |
var shadowOpacity: Float { get set } | |
} | |
@IBDesignable extension UIView: DesignableShadow { |
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
protocol DesignableBorder { | |
var cornerRadius: CGFloat { get set } | |
var borderWidth: CGFloat { get set } | |
var borderColor: UIColor? { get set } | |
} | |
@IBDesignable extension UIView: DesignableBorder { |
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
/// An extension to provide conversion to and from RGBA (red, green, blue, alpha) colors. | |
extension UIColor { | |
/// The RGBA (red, green, blue, alpha) components of a color, in the range [0, 255]. | |
struct RGBA: Hashable { | |
/// The red component of the color, in the range [0, 255]. | |
var red: Int | |
/// The green component of the color, in the range [0, 255]. | |
var green: Int |
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
/// An extension to provide conversion to and from ARGB (alpha, red, green, blue) colors. | |
extension UIColor { | |
/// The ARGB (alpha, red, green, blue) components of a color, in the range [0, 255]. | |
struct ARGB: Hashable { | |
/// The alpha component of the color, in the range [0, 255]. | |
var alpha: Int | |
/// The red component of the color, in the range [0, 255]. | |
var red: Int |
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
/// An extension to provide conversion to and from HSV (hue, saturation, value) colors. | |
extension UIColor { | |
/// The HSV (hue, saturation, value) components of a color. | |
struct HSV: Hashable { | |
/// The hue component of the color, in the range [0, 360°]. | |
var hue: CGFloat | |
/// The saturation component of the color, in the range [0, 100%]. | |
var saturation: CGFloat |
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
/// An extension to provide conversion to and from CIELAB colors. | |
extension UIColor { | |
/// The CIELAB components of a color - lightness (L) and chromaticity (a,b). | |
struct CIELAB: Hashable { | |
/// The lightness component of the color, in the range [0, 100] (darkest to brightest). | |
var L: CGFloat | |
/// The green-red chromaticity component of the color, typically in the range [-128, 128]. | |
var a: CGFloat |