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 } -
endColorDefault implementationEnd color of gradient, by default 0.5 ligher or darker of
startColorDefault Implementation
End color of gradient, by default 0.5 ligher or darker of
startColorDeclaration
Swift
var endColor: UIColor { get } -
startPointDefault implementationStart point for gradient
Default Implementation
Default start point for gradient is (0.0, 0.5)
Declaration
Swift
var startPoint: CGPoint { get } -
endPointDefault implementationEnd point for gradient
Default Implementation
Default end point for gradient is (1.0, 0.5)
Declaration
Swift
var endPoint: CGPoint { get }
-
colorsExtension methodProvides list of
CGColorto create gradient usingCAGradientLayerDeclaration
Swift
var colors: [CGColor] { get }
View on GitHub
Install in Dash
GradientColor Protocol Reference