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)