Right now I\'ve got a GA Gradient layer where I\'ve set the colors but I\'d like to set the color point to (instead of top center, to top left) and the bottom to (instead of
The startPoint
and endPoint
properties of a CAGradientLayer
are defined in the “unit coordinate system”. In the unit coordinate system:
(0,0)
corresponds to the smallest coordinates of the layer's bounds rectangle, which on iOS is its upper-left corner unless the layer has been transformed;(1,1)
corresponds to the largest coordinates of the layer's bounds rectangle, which on iOS is its lower-right corner unless the layer has been transformed.Thus arranging your gradient the way you want should be this simple:
gradient.startPoint = CGPoint.zero
gradient.endPoint = CGPoint(x: 1, y: 1)