If I’m remembering correctly, addSubLayer put the gradient on top of everything else instead of behind. That’s because addSubLayer adds the new layer to the end of the sublayers array, and the items in the sublayers array are drawn in order - sublayers[0] is drawn first, then sublayers[1] is drawn on top of that, and so on. If the gradient is at the end of the array it is drawn last, blocking out everything that was drawn before it, so you have to make sure it gets drawn first by inserting it at the beginning of the array. And because we’re adding the gradient in viewDidload, the other items on the screen are already in the array.
1 Like