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
/// A type that can be loaded from an associated nib. | |
protocol NibLoadable: class { | |
/// The name of the nib for the loadable class. | |
static var nibName: String { get } | |
/// The bundle the nib is contained within for the loadable class. | |
static var nibBundle: Bundle { get } | |
} |
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
@IBDesignable class DismissSegue: UIStoryboardSegue { | |
var completion: (() -> Void)? | |
override func perform() { | |
self.source.presentingViewController?.dismiss(animated: UIView.areAnimationsEnabled, completion: self.completion) | |
} | |
} |
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 instantiate and represent RGB colors as hexadecimal values. | |
extension UIColor { | |
/// Initializes a color from a hexadecimal integer in the RGB format (RRGGBB), e.g., 0xffff00. | |
/// - parameter hex: The hexadecimal value of the color. | |
/// - parameter alpha: The alpha value of the color. | |
convenience init(hex: Int, alpha: CGFloat = 1.0) { | |
let rgb = ( | |
r: CGFloat((hex >> 16) & 0xff) / 0xff, | |
g: CGFloat((hex >> 08) & 0xff) / 0xff, |
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 RGB (red, green, blue) colors. | |
extension UIColor { | |
/// The RGB (red, green, blue) components of a color, in the range [0, 255]. | |
struct RGB: 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 CMYK (cyan, magenta, yellow, black) colors. | |
extension UIColor { | |
/// The CMYK (cyan, magenta, yellow, black) components of a color, in the range [0, 100%]. | |
struct CMYK: Hashable { | |
/// The cyan component of the color, in the range [0, 100%]. | |
var cyan: CGFloat | |
/// The magenta component of the color, in the range [0, 100%]. | |
var magenta: 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 HSB (hue, saturation, brightness) colors. | |
extension UIColor { | |
/// The HSB (hue, saturation, brightness) components of a color. | |
struct HSB: 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 HSL (hue, saturation, lightness) colors. | |
extension UIColor { | |
/// The HSL (hue, saturation, lightness) components of a color. | |
struct HSL: 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 Y′CbCr colors. | |
extension UIColor { | |
/// The Rec.601 (standard-definition) coefficients used to calculate luma. | |
private static let encoding: (r: CGFloat, g: CGFloat, b: CGFloat) = (0.299, 0.587, 0.114) | |
/// The Y′CbCr components of a color - luma (Y′) and chroma (Cb,Cr). | |
struct YCbCr: Hashable { | |
/// The luma component of the color, in the full range [0, 255] (black to white). |
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 1931 XYZ colors. | |
extension UIColor { | |
/// The CIE 1931 XYZ components of a color - luminance (Y) and chromaticity (X,Z). | |
struct CIEXYZ: Hashable { | |
/// A mix of cone response curves chosen to be orthogonal to luminance and | |
/// non-negative, in the range [0, 95.047]. | |
var X: CGFloat | |
/// The luminance component of the color, in the range [0, 100]. |
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 |
OlderNewer