StyleColor
public struct StyleColor : Codable, Equatable, RawRepresentable, ExpressibleByStringInterpolation
Represents a color as defined by the Mapbox Style Spec
-
A color string as defined by the Mapbox Style Spec.
Declaration
Swift
public let rawValue: String
-
Creates a
StyleColorfrom individually-provided color components. Returns nil if any of the channel values are out of the supported ranges.Declaration
Swift
public init?(red: Double, green: Double, blue: Double)Parameters
redA value from 0 to 255, as required by the Mapbox Style Spec
greenA value from 0 to 255, as required by the Mapbox Style Spec
blueA value from 0 to 255, as required by the Mapbox Style Spec
-
Creates a
StyleColorfrom individually-provided color components. Returns nil if any of the channel values are out of the supported ranges.Declaration
Swift
public init?(red: Double, green: Double, blue: Double, alpha: Double)Parameters
redA value from 0 to 255, as required by the Mapbox Style Spec
greenA value from 0 to 255, as required by the Mapbox Style Spec
blueA value from 0 to 255, as required by the Mapbox Style Spec
alphaA value from 0 to 1, as required by the Mapbox Style Spec
-
Creates a
StyleColorfrom individually-provided color components. Returns nil if any of the channel values are out of the supported ranges.Declaration
Swift
public init?(hue: Double, saturation: Double, lightness: Double)Parameters
hueA value from 0 to 360, as required by the Mapbox Style Spec
saturationA value from 0 to 100, as required by the Mapbox Style Spec
lightnessA value from 0 to 100, as required by the Mapbox Style Spec
-
Creates a
StyleColorfrom individually-provided color components. Returns nil if any of the channel values are out of the supported ranges.Declaration
Swift
public init?(hue: Double, saturation: Double, lightness: Double, alpha: Double)Parameters
hueA value from 0 to 360, as required by the Mapbox Style Spec
saturationA value from 0 to 100, as required by the Mapbox Style Spec
lightnessA value from 0 to 100, as required by the Mapbox Style Spec
alphaA value from 0 to 1, as required by the Mapbox Style Spec
-
Creates a
StyleColorfrom aUIColorDeclaration
Swift
public init(_ color: UIColor)Parameters
colorA
UIColorin the sRGB color space
-
Creates a
StyleColorfrom a color string as defined in the Mapbox Style Spec.Declaration
Swift
public init(rawValue: String)Parameters
rawValueA color string.
-
Declaration
Swift
public init(stringLiteral value: StringLiteralType)
-
StyleColorcan be decoded from an rgba expression or from an rgba color stringThrows
Throws if neither an rgba expression nor an rbga color string could be decoded.Declaration
Swift
public init(from decoder: Decoder) throwsParameters
decoderThe decoder from which the
StyleColorwill attempt to decode an rgba expression or rgba color string -
StyleColoris always encoded to an rgba color stringThrows
Throws if the provided encoder does not allow encoding the rgba color string.Declaration
Swift
public func encode(to encoder: Encoder) throwsParameters
encoderThe encoder to which the rgba color string is encoded
StyleColor Structure Reference