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)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With