I am trying to draw a gradient in the background View Viewer with iOS 9, but I do not know why, does not work
Here is my method that is called from viewDidLoad
- (void)drawGradient
{
CAGradientLayer *gradient = [CAGradientLayer layer];
gradient.frame = self.view.bounds;
gradient.colors = @[[UIColor greenColor], [UIColor redColor]];
gradient.locations = @[@0.0, @1.0];
[self.view.layer insertSublayer:gradient atIndex:0];
}
But nothing happens, and the gradient does not appear. What am I doing wrong?
source
share