This is my code for a gradient background. When I apply it on my view, it hides all my stuff on that VC, like it\'s on the front and everything else is pushed back. How can I ma
like it is on the front and everything else is pushed back
Because it is on the front. Think about this line of your code:
layer.addSublayer(gradientLayer)
That puts the gradient layer in front of all other sublayers of this layer. Subviews of a view are displayed by sublayers of its layer, so the gradient layer covers this view's current subviews.
You can insert your layer all the way at the back if you like (insertSublayer:atIndex:
). The elegant solution, though, is to implement the layerClass class method for this view to return a CAGradientLayer. Now you won't have to add a gradient to your GradientView; instead, your GradientView is a gradient and you can just configure that gradient as desired.