In viewDidLoad, under autolayout, your views will not yet have a frame, so you are making the layer have a frame of CGRectZero
.
You need to move this code, or at least the part where you set the frame of the gradient layer, to viewDidLayoutSubviews
or similar.