GradientColor

public protocol GradientColor

GradientColor protocol provides gradient defination with start & end colors and start & end points. Helper to create gradient using CAGradientLayer.

// Left-to-Right gradient color can be defined as below
struct CardGradientColor: GradientColor {
let startColor = UIColor("#1e3c72")
let endColor =  UIColor("#2a5298")
}

// Single color with darker/light shade gradient color can be defined as below.
//`endColor` will be darker or ligher of `startColor`
struct ShadedGradientColor: GradientColor {
let startColor = UIColor("#1e3c72")
}

UIColor also implements GradientColor protocol, so instance of UIColor can be used directly wherever GradientColor used.

See also

SeeAlso:- GradientView

See also

SeeAlso:- `public convenience init(gradient: GradientColor)
  • Start color of gradient

    Declaration

    Swift

    var startColor: UIColor { get }
  • endColor Default implementation

    End color of gradient, by default 0.5 ligher or darker of startColor

    Default Implementation

    End color of gradient, by default 0.5 ligher or darker of startColor

    Declaration

    Swift

    var endColor: UIColor { get }
  • startPoint Default implementation

    Start point for gradient

    Default Implementation

    Default start point for gradient is (0.0, 0.5)

    Declaration

    Swift

    var startPoint: CGPoint { get }
  • endPoint Default implementation

    End point for gradient

    Default Implementation

    Default end point for gradient is (1.0, 0.5)

    Declaration

    Swift

    var endPoint: CGPoint { get }
  • colors Extension method

    Provides list of CGColor to create gradient using CAGradientLayer

    Declaration

    Swift

    var colors: [CGColor] { get }