Stats

266 Contributors: 5 Wednesday, February 8, 2017
Licensed under: CC-BY-SA
Not affiliated with Stack Overflow
Rip Tutorial: riptutorial@gmail.com
Roadmap: roadmap

CAGradientLayer

Syntax

  • CAGradientLayer() // Returns an initialized CALayer object.
  • CAGradientLayer(layer: layer) // Override to copy or initialize custom fields of the specified layer.

Parameters

ParameterDetails
colorAn array of CGColorRef objects defining the color of each gradient stop. Animatable.
locationsAn optional array of NSNumber objects defining the location of each gradient stop. Animatable.
endPointThe end point of the gradient when drawn in the layer’s coordinate space. Animatable.
startPointThe start point of the gradient when drawn in the layer’s coordinate space. Animatable.
typeStyle of gradient drawn by the layer. Defaults to kCAGradientLayerAxial.

Remarks

  • Use startPoint and endPoint to change the orientation of the CAGradientLayer.
  • Use the locations to affect the spread/positions of the colors.

Related Examples