Fix Xcode 10.2 warnings
This commit is contained in:
parent
df00efcdae
commit
9070b3a7de
|
@ -1 +1 @@
|
|||
4.2
|
||||
5
|
|
@ -1,5 +1,5 @@
|
|||
language: objective-c
|
||||
osx_image: xcode9
|
||||
osx_image: xcode10.2
|
||||
script:
|
||||
- brew install swiftlint || brew upgrade swiftlint
|
||||
- swiftlint lint --path Sources/ --config ../.swiftlint.yml
|
||||
|
|
|
@ -702,7 +702,7 @@
|
|||
CreatedOnToolsVersion = 6.3.2;
|
||||
DevelopmentTeam = 5SJ773RP6R;
|
||||
DevelopmentTeamName = "Work And Play";
|
||||
LastSwiftMigration = 1000;
|
||||
LastSwiftMigration = 1020;
|
||||
};
|
||||
CEE753C91BF105E3001FF6ED = {
|
||||
CreatedOnToolsVersion = 7.1;
|
||||
|
@ -714,13 +714,13 @@
|
|||
CEFBDADA1B1CE38D000E6F30 = {
|
||||
CreatedOnToolsVersion = 6.3.2;
|
||||
DevelopmentTeamName = "Work And Play";
|
||||
LastSwiftMigration = 1000;
|
||||
LastSwiftMigration = 1020;
|
||||
};
|
||||
};
|
||||
};
|
||||
buildConfigurationList = CEFBDAD61B1CE38D000E6F30 /* Build configuration list for PBXProject "DynamicColorExample" */;
|
||||
compatibilityVersion = "Xcode 8.0";
|
||||
developmentRegion = English;
|
||||
developmentRegion = en;
|
||||
hasScannedForEncodings = 0;
|
||||
knownRegions = (
|
||||
en,
|
||||
|
@ -1079,7 +1079,7 @@
|
|||
SDKROOT = macosx;
|
||||
SKIP_INSTALL = YES;
|
||||
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
|
||||
SWIFT_VERSION = 3.0;
|
||||
SWIFT_VERSION = 5.0;
|
||||
VERSIONING_SYSTEM = "apple-generic";
|
||||
VERSION_INFO_PREFIX = "";
|
||||
};
|
||||
|
@ -1108,7 +1108,7 @@
|
|||
SDKROOT = macosx;
|
||||
SKIP_INSTALL = YES;
|
||||
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
|
||||
SWIFT_VERSION = 3.0;
|
||||
SWIFT_VERSION = 5.0;
|
||||
VERSIONING_SYSTEM = "apple-generic";
|
||||
VERSION_INFO_PREFIX = "";
|
||||
};
|
||||
|
@ -1135,7 +1135,7 @@
|
|||
SDKROOT = appletvos;
|
||||
SKIP_INSTALL = YES;
|
||||
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
|
||||
SWIFT_VERSION = 3.0;
|
||||
SWIFT_VERSION = 5.0;
|
||||
TARGETED_DEVICE_FAMILY = 3;
|
||||
TVOS_DEPLOYMENT_TARGET = 9.0;
|
||||
VERSIONING_SYSTEM = "apple-generic";
|
||||
|
@ -1163,7 +1163,7 @@
|
|||
SDKROOT = appletvos;
|
||||
SKIP_INSTALL = YES;
|
||||
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
|
||||
SWIFT_VERSION = 3.0;
|
||||
SWIFT_VERSION = 5.0;
|
||||
TARGETED_DEVICE_FAMILY = 3;
|
||||
TVOS_DEPLOYMENT_TARGET = 9.0;
|
||||
VERSIONING_SYSTEM = "apple-generic";
|
||||
|
@ -1193,7 +1193,7 @@
|
|||
SDKROOT = watchos;
|
||||
SKIP_INSTALL = YES;
|
||||
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
|
||||
SWIFT_VERSION = 3.0;
|
||||
SWIFT_VERSION = 5.0;
|
||||
TARGETED_DEVICE_FAMILY = 4;
|
||||
VERSIONING_SYSTEM = "apple-generic";
|
||||
VERSION_INFO_PREFIX = "";
|
||||
|
@ -1222,7 +1222,7 @@
|
|||
SDKROOT = watchos;
|
||||
SKIP_INSTALL = YES;
|
||||
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
|
||||
SWIFT_VERSION = 3.0;
|
||||
SWIFT_VERSION = 5.0;
|
||||
TARGETED_DEVICE_FAMILY = 4;
|
||||
VERSIONING_SYSTEM = "apple-generic";
|
||||
VERSION_INFO_PREFIX = "";
|
||||
|
@ -1246,7 +1246,7 @@
|
|||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
|
||||
SWIFT_SWIFT3_OBJC_INFERENCE = On;
|
||||
SWIFT_VERSION = 4.2;
|
||||
SWIFT_VERSION = 5.0;
|
||||
};
|
||||
name = Debug;
|
||||
};
|
||||
|
@ -1265,7 +1265,7 @@
|
|||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
|
||||
SWIFT_SWIFT3_OBJC_INFERENCE = On;
|
||||
SWIFT_VERSION = 4.2;
|
||||
SWIFT_VERSION = 5.0;
|
||||
};
|
||||
name = Release;
|
||||
};
|
||||
|
@ -1290,7 +1290,7 @@
|
|||
PRODUCT_BUNDLE_IDENTIFIER = "com.yannickloriot.$(PRODUCT_NAME:rfc1034identifier)";
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SKIP_INSTALL = YES;
|
||||
SWIFT_VERSION = 4.2;
|
||||
SWIFT_VERSION = 5.0;
|
||||
VERSIONING_SYSTEM = "apple-generic";
|
||||
VERSION_INFO_PREFIX = "";
|
||||
};
|
||||
|
@ -1314,7 +1314,7 @@
|
|||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SKIP_INSTALL = YES;
|
||||
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
|
||||
SWIFT_VERSION = 4.2;
|
||||
SWIFT_VERSION = 5.0;
|
||||
VERSIONING_SYSTEM = "apple-generic";
|
||||
VERSION_INFO_PREFIX = "";
|
||||
};
|
||||
|
@ -1334,7 +1334,7 @@
|
|||
PRODUCT_BUNDLE_IDENTIFIER = com.yannickloriot.OSXTests;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SDKROOT = macosx;
|
||||
SWIFT_VERSION = 3.0;
|
||||
SWIFT_VERSION = 5.0;
|
||||
};
|
||||
name = Debug;
|
||||
};
|
||||
|
@ -1352,7 +1352,7 @@
|
|||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SDKROOT = macosx;
|
||||
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
|
||||
SWIFT_VERSION = 3.0;
|
||||
SWIFT_VERSION = 5.0;
|
||||
};
|
||||
name = Release;
|
||||
};
|
||||
|
@ -1368,7 +1368,7 @@
|
|||
PRODUCT_BUNDLE_IDENTIFIER = com.yannickloriot.TVExample;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SDKROOT = appletvos;
|
||||
SWIFT_VERSION = 3.0;
|
||||
SWIFT_VERSION = 5.0;
|
||||
TARGETED_DEVICE_FAMILY = 3;
|
||||
TVOS_DEPLOYMENT_TARGET = 9.0;
|
||||
};
|
||||
|
@ -1386,7 +1386,7 @@
|
|||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SDKROOT = appletvos;
|
||||
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
|
||||
SWIFT_VERSION = 3.0;
|
||||
SWIFT_VERSION = 5.0;
|
||||
TARGETED_DEVICE_FAMILY = 3;
|
||||
TVOS_DEPLOYMENT_TARGET = 9.0;
|
||||
};
|
||||
|
@ -1512,7 +1512,7 @@
|
|||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
|
||||
PRODUCT_BUNDLE_IDENTIFIER = "com.yannickloriot.$(PRODUCT_NAME:rfc1034identifier)";
|
||||
PRODUCT_NAME = DynamicColorExample;
|
||||
SWIFT_VERSION = 4.2;
|
||||
SWIFT_VERSION = 5.0;
|
||||
};
|
||||
name = Debug;
|
||||
};
|
||||
|
@ -1527,7 +1527,7 @@
|
|||
PRODUCT_BUNDLE_IDENTIFIER = "com.yannickloriot.$(PRODUCT_NAME:rfc1034identifier)";
|
||||
PRODUCT_NAME = DynamicColorExample;
|
||||
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
|
||||
SWIFT_VERSION = 4.2;
|
||||
SWIFT_VERSION = 5.0;
|
||||
};
|
||||
name = Release;
|
||||
};
|
||||
|
|
|
@ -12,7 +12,7 @@ import UIKit
|
|||
class AppDelegate: UIResponder, UIApplicationDelegate {
|
||||
var window: UIWindow?
|
||||
|
||||
func application(_ application: UIApplication, willFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey : Any]? = nil) -> Bool {
|
||||
func application(_ application: UIApplication, willFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil) -> Bool {
|
||||
// Override point for customization after application launch.
|
||||
return true
|
||||
}
|
||||
|
|
|
@ -33,7 +33,7 @@ public extension Array where Element: DynamicColor {
|
|||
/**
|
||||
Gradient representation of the array.
|
||||
*/
|
||||
public var gradient: DynamicGradient {
|
||||
var gradient: DynamicGradient {
|
||||
return DynamicGradient(colors: self)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -39,7 +39,7 @@ public extension DynamicColor {
|
|||
- parameter amount: A float representing the number of degrees as ratio (usually between -360.0 degree and 360.0 degree).
|
||||
- returns: A DynamicColor object with the hue changed.
|
||||
*/
|
||||
public final func adjustedHue(amount: CGFloat) -> DynamicColor {
|
||||
final func adjustedHue(amount: CGFloat) -> DynamicColor {
|
||||
return HSL(color: self).adjustedHue(amount: amount).toDynamicColor()
|
||||
}
|
||||
|
||||
|
@ -51,7 +51,7 @@ public extension DynamicColor {
|
|||
- returns: The complement DynamicColor.
|
||||
- seealso: adjustedHueColor:
|
||||
*/
|
||||
public final func complemented() -> DynamicColor {
|
||||
final func complemented() -> DynamicColor {
|
||||
return adjustedHue(amount: 180)
|
||||
}
|
||||
|
||||
|
@ -61,7 +61,7 @@ public extension DynamicColor {
|
|||
- parameter amount: CGFloat between 0.0 and 1.0. Default value is 0.2.
|
||||
- returns: A lighter DynamicColor.
|
||||
*/
|
||||
public final func lighter(amount: CGFloat = 0.2) -> DynamicColor {
|
||||
final func lighter(amount: CGFloat = 0.2) -> DynamicColor {
|
||||
return HSL(color: self).lighter(amount: amount).toDynamicColor()
|
||||
}
|
||||
|
||||
|
@ -71,7 +71,7 @@ public extension DynamicColor {
|
|||
- parameter amount: Float between 0.0 and 1.0. Default value is 0.2.
|
||||
- returns: A darker DynamicColor.
|
||||
*/
|
||||
public final func darkened(amount: CGFloat = 0.2) -> DynamicColor {
|
||||
final func darkened(amount: CGFloat = 0.2) -> DynamicColor {
|
||||
return HSL(color: self).darkened(amount: amount).toDynamicColor()
|
||||
}
|
||||
|
||||
|
@ -82,7 +82,7 @@ public extension DynamicColor {
|
|||
|
||||
- returns: A DynamicColor more saturated.
|
||||
*/
|
||||
public final func saturated(amount: CGFloat = 0.2) -> DynamicColor {
|
||||
final func saturated(amount: CGFloat = 0.2) -> DynamicColor {
|
||||
return HSL(color: self).saturated(amount: amount).toDynamicColor()
|
||||
}
|
||||
|
||||
|
@ -92,7 +92,7 @@ public extension DynamicColor {
|
|||
- parameter amount: CGFloat between 0.0 and 1.0. Default value is 0.2.
|
||||
- returns: A DynamicColor less saturated.
|
||||
*/
|
||||
public final func desaturated(amount: CGFloat = 0.2) -> DynamicColor {
|
||||
final func desaturated(amount: CGFloat = 0.2) -> DynamicColor {
|
||||
return HSL(color: self).desaturated(amount: amount).toDynamicColor()
|
||||
}
|
||||
|
||||
|
@ -104,7 +104,7 @@ public extension DynamicColor {
|
|||
- returns: A grayscale DynamicColor.
|
||||
- seealso: desaturateColor:
|
||||
*/
|
||||
public final func grayscaled() -> DynamicColor {
|
||||
final func grayscaled() -> DynamicColor {
|
||||
return desaturated(amount: 1)
|
||||
}
|
||||
|
||||
|
@ -113,7 +113,7 @@ public extension DynamicColor {
|
|||
|
||||
- returns: An inverse (negative) of the original color.
|
||||
*/
|
||||
public final func inverted() -> DynamicColor {
|
||||
final func inverted() -> DynamicColor {
|
||||
let rgba = toRGBAComponents()
|
||||
|
||||
let invertedRed = 1 - rgba.r
|
||||
|
|
|
@ -43,7 +43,7 @@ public extension DynamicColor {
|
|||
- parameter b: The yellow-blue axis, specified as a value from -128.0 to 127.0.
|
||||
- parameter alpha: The opacity value of the color object, specified as a value from 0.0 to 1.0. Default to 1.0.
|
||||
*/
|
||||
public convenience init(L: CGFloat, a: CGFloat, b: CGFloat, alpha: CGFloat = 1) {
|
||||
convenience init(L: CGFloat, a: CGFloat, b: CGFloat, alpha: CGFloat = 1) {
|
||||
let clippedL = clip(L, 0, 100)
|
||||
let clippedA = clip(a, -128, 127)
|
||||
let clippedB = clip(b, -128, 127)
|
||||
|
@ -73,7 +73,7 @@ public extension DynamicColor {
|
|||
|
||||
- returns: The L*a*b* components as a tuple (L, a, b).
|
||||
*/
|
||||
public final func toLabComponents() -> (L: CGFloat, a: CGFloat, b: CGFloat) {
|
||||
final func toLabComponents() -> (L: CGFloat, a: CGFloat, b: CGFloat) {
|
||||
let normalized = { (c: CGFloat) -> CGFloat in
|
||||
c > 0.008856 ? pow(c, 1.0 / 3) : 7.787 * c + 16.0 / 116
|
||||
}
|
||||
|
|
|
@ -45,7 +45,7 @@ public extension DynamicColor {
|
|||
- Parameter colorspace: The color space used to mix the colors. By default it uses the RBG color space.
|
||||
- Returns: A color object corresponding to the two colors object mixed together.
|
||||
*/
|
||||
public final func mixed(withColor color: DynamicColor, weight: CGFloat = 0.5, inColorSpace colorspace: DynamicColorSpace = .rgb) -> DynamicColor {
|
||||
final func mixed(withColor color: DynamicColor, weight: CGFloat = 0.5, inColorSpace colorspace: DynamicColorSpace = .rgb) -> DynamicColor {
|
||||
let normalizedWeight = clip(weight, 0, 1)
|
||||
|
||||
switch colorspace {
|
||||
|
@ -66,7 +66,7 @@ public extension DynamicColor {
|
|||
- Parameter amount: Float between 0.0 and 1.0. The default amount is equal to 0.2.
|
||||
- Returns: A lighter DynamicColor.
|
||||
*/
|
||||
public final func tinted(amount: CGFloat = 0.2) -> DynamicColor {
|
||||
final func tinted(amount: CGFloat = 0.2) -> DynamicColor {
|
||||
return mixed(withColor: .white, weight: amount)
|
||||
}
|
||||
|
||||
|
@ -76,7 +76,7 @@ public extension DynamicColor {
|
|||
- Parameter amount: Float between 0.0 and 1.0. The default amount is equal to 0.2.
|
||||
- Returns: A darker DynamicColor.
|
||||
*/
|
||||
public final func shaded(amount: CGFloat = 0.2) -> DynamicColor {
|
||||
final func shaded(amount: CGFloat = 0.2) -> DynamicColor {
|
||||
return mixed(withColor: DynamicColor(red: 0, green: 0, blue: 0, alpha: 1), weight: amount)
|
||||
}
|
||||
|
||||
|
|
|
@ -43,7 +43,7 @@ public extension DynamicColor {
|
|||
- Parameter b: The blue component of the color object, specified as a value from 0.0 to 255.0.
|
||||
- Parameter a: The opacity value of the color object, specified as a value from 0.0 to 255.0. The default value is 255.
|
||||
*/
|
||||
public convenience init(r: CGFloat, g: CGFloat, b: CGFloat, a: CGFloat = 255) {
|
||||
convenience init(r: CGFloat, g: CGFloat, b: CGFloat, a: CGFloat = 255) {
|
||||
self.init(red: clip(r, 0, 255) / 255, green: clip(g, 0, 255) / 255, blue: clip(b, 0, 255) / 255, alpha: clip(a, 0, 255) / 255)
|
||||
}
|
||||
|
||||
|
@ -54,7 +54,7 @@ public extension DynamicColor {
|
|||
|
||||
- returns: The RGBA components as a tuple (r, g, b, a).
|
||||
*/
|
||||
public final func toRGBAComponents() -> (r: CGFloat, g: CGFloat, b: CGFloat, a: CGFloat) {
|
||||
final func toRGBAComponents() -> (r: CGFloat, g: CGFloat, b: CGFloat, a: CGFloat) {
|
||||
var r: CGFloat = 0, g: CGFloat = 0, b: CGFloat = 0, a: CGFloat = 0
|
||||
|
||||
#if os(iOS) || os(tvOS) || os(watchOS)
|
||||
|
@ -79,28 +79,28 @@ public extension DynamicColor {
|
|||
/**
|
||||
The red component as CGFloat between 0.0 to 1.0.
|
||||
*/
|
||||
public final var redComponent: CGFloat {
|
||||
final var redComponent: CGFloat {
|
||||
return toRGBAComponents().r
|
||||
}
|
||||
|
||||
/**
|
||||
The green component as CGFloat between 0.0 to 1.0.
|
||||
*/
|
||||
public final var greenComponent: CGFloat {
|
||||
final var greenComponent: CGFloat {
|
||||
return toRGBAComponents().g
|
||||
}
|
||||
|
||||
/**
|
||||
The blue component as CGFloat between 0.0 to 1.0.
|
||||
*/
|
||||
public final var blueComponent: CGFloat {
|
||||
final var blueComponent: CGFloat {
|
||||
return toRGBAComponents().b
|
||||
}
|
||||
|
||||
/**
|
||||
The alpha component as CGFloat between 0.0 to 1.0.
|
||||
*/
|
||||
public final var alphaComponent: CGFloat {
|
||||
final var alphaComponent: CGFloat {
|
||||
return toRGBAComponents().a
|
||||
}
|
||||
#endif
|
||||
|
@ -113,7 +113,7 @@ public extension DynamicColor {
|
|||
- parameter amount: CGFloat between 0.0 and 1.0.
|
||||
- returns: A color object with its alpha channel modified.
|
||||
*/
|
||||
public final func adjustedAlpha(amount: CGFloat) -> DynamicColor {
|
||||
final func adjustedAlpha(amount: CGFloat) -> DynamicColor {
|
||||
let components = toRGBAComponents()
|
||||
let normalizedAlpha = clip(components.a + amount, 0, 1)
|
||||
|
||||
|
|
|
@ -43,7 +43,7 @@ public extension DynamicColor {
|
|||
- parameter Z: The quasi-equal to blue stimulation, specified as a value from 0 to 108.9.
|
||||
- parameter alpha: The opacity value of the color object, specified as a value from 0.0 to 1.0. Default to 1.0.
|
||||
*/
|
||||
public convenience init(X: CGFloat, Y: CGFloat, Z: CGFloat, alpha: CGFloat = 1) {
|
||||
convenience init(X: CGFloat, Y: CGFloat, Z: CGFloat, alpha: CGFloat = 1) {
|
||||
let clippedX = clip(X, 0, 95.05) / 100
|
||||
let clippedY = clip(Y, 0, 100) / 100
|
||||
let clippedZ = clip(Z, 0, 108.9) / 100
|
||||
|
@ -70,7 +70,7 @@ public extension DynamicColor {
|
|||
|
||||
- returns: The XYZ components as a tuple (X, Y, Z).
|
||||
*/
|
||||
public final func toXYZComponents() -> (X: CGFloat, Y: CGFloat, Z: CGFloat) {
|
||||
final func toXYZComponents() -> (X: CGFloat, Y: CGFloat, Z: CGFloat) {
|
||||
let toSRGB = { (c: CGFloat) -> CGFloat in
|
||||
c > 0.04045 ? pow((c + 0.055) / 1.055, 2.4) : c / 12.92
|
||||
}
|
||||
|
|
|
@ -54,7 +54,7 @@ public extension DynamicColor {
|
|||
|
||||
- parameter hexString: A hexa-decimal color string representation.
|
||||
*/
|
||||
public convenience init(hexString: String) {
|
||||
convenience init(hexString: String) {
|
||||
let hexString = hexString.trimmingCharacters(in: .whitespacesAndNewlines)
|
||||
let scanner = Scanner(string: hexString)
|
||||
|
||||
|
@ -78,7 +78,7 @@ public extension DynamicColor {
|
|||
- parameter hex: A hexa-decimal UInt32 that represents a color.
|
||||
- parameter alphaChannel: If true the given hex-decimal UInt32 includes the alpha channel (e.g. 0xFF0000FF).
|
||||
*/
|
||||
public convenience init(hex: UInt32, useAlpha alphaChannel: Bool = false) {
|
||||
convenience init(hex: UInt32, useAlpha alphaChannel: Bool = false) {
|
||||
let mask = UInt32(0xFF)
|
||||
let cappedHex = !alphaChannel && hex > 0xffffff ? 0xffffff : hex
|
||||
|
||||
|
@ -100,7 +100,7 @@ public extension DynamicColor {
|
|||
|
||||
- returns: A string similar to this pattern "#f4003b".
|
||||
*/
|
||||
public final func toHexString() -> String {
|
||||
final func toHexString() -> String {
|
||||
return String(format: "#%06x", toHex())
|
||||
}
|
||||
|
||||
|
@ -109,7 +109,7 @@ public extension DynamicColor {
|
|||
|
||||
- returns: A UInt32 that represents the hexa-decimal color.
|
||||
*/
|
||||
public final func toHex() -> UInt32 {
|
||||
final func toHex() -> UInt32 {
|
||||
func roundToHex(_ x: CGFloat) -> UInt32 {
|
||||
guard x > 0 else { return 0 }
|
||||
let rounded: CGFloat = round(x * 255)
|
||||
|
@ -131,7 +131,7 @@ public extension DynamicColor {
|
|||
- parameter hexString: A hexa-decimal color number representation to be compared to the receiver.
|
||||
- returns: true if the receiver and the string are equals, otherwise false.
|
||||
*/
|
||||
public func isEqual(toHexString hexString: String) -> Bool {
|
||||
func isEqual(toHexString hexString: String) -> Bool {
|
||||
return self.toHexString() == hexString
|
||||
}
|
||||
|
||||
|
@ -141,7 +141,7 @@ public extension DynamicColor {
|
|||
- parameter hex: A UInt32 that represents the hexa-decimal color.
|
||||
- returns: true if the receiver and the integer are equals, otherwise false.
|
||||
*/
|
||||
public func isEqual(toHex hex: UInt32) -> Bool {
|
||||
func isEqual(toHex hex: UInt32) -> Bool {
|
||||
return self.toHex() == hex
|
||||
}
|
||||
|
||||
|
@ -154,7 +154,7 @@ public extension DynamicColor {
|
|||
|
||||
- returns: A boolean value to know whether the color is light. If true the color is light, dark otherwise.
|
||||
*/
|
||||
public func isLight() -> Bool {
|
||||
func isLight() -> Bool {
|
||||
let components = toRGBAComponents()
|
||||
let brightness = ((components.r * 299) + (components.g * 587) + (components.b * 114)) / 1000
|
||||
|
||||
|
@ -166,7 +166,7 @@ public extension DynamicColor {
|
|||
|
||||
We use the formula described by W3C in WCAG 2.0. You can read more here: https://www.w3.org/TR/WCAG20/#relativeluminancedef.
|
||||
*/
|
||||
public var luminance: CGFloat {
|
||||
var luminance: CGFloat {
|
||||
let components = toRGBAComponents()
|
||||
|
||||
let componentsArray = [components.r, components.g, components.b].map { (val) -> CGFloat in
|
||||
|
@ -186,7 +186,7 @@ public extension DynamicColor {
|
|||
|
||||
- returns: A CGFloat representing contrast value.
|
||||
*/
|
||||
public func contrastRatio(with otherColor: DynamicColor) -> CGFloat {
|
||||
func contrastRatio(with otherColor: DynamicColor) -> CGFloat {
|
||||
let otherLuminance = otherColor.luminance
|
||||
|
||||
let l1 = max(luminance, otherLuminance)
|
||||
|
@ -209,7 +209,7 @@ public extension DynamicColor {
|
|||
|
||||
- returns: true is the contrast ratio between 2 colors exceed the minimum acceptable ratio.
|
||||
*/
|
||||
public func isContrasting(with otherColor: DynamicColor, inContext context: ContrastDisplayContext = .standard) -> Bool {
|
||||
func isContrasting(with otherColor: DynamicColor, inContext context: ContrastDisplayContext = .standard) -> Bool {
|
||||
return self.contrastRatio(with: otherColor) > context.minimumContrastRatio
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue