To add a background gradient to a UILabel I use the following code.
Before using the gradient, UILabel Appears like this.
Now, to add a gradient I use the following code.
CAGradientLayer *gradLayer=[CAGradientLayer layer];
gradLayer.frame=self.myView.layer.bounds;
[gradLayer setColors:[NSArray arrayWithObjects:(id)([UIColor redColor].CGColor), (id)([UIColor cyanColor].CGColor),nil]];
gradLayer.endPoint=CGPointMake(1.0, 0.0);
[self.myView.layer addSublayer:gradLayer];
The UILabel then is as follows, but with no text.
I also try to add the layer at the bottom of the UILabel layer but no success.
[self.myView.layer insertSublayer:gradLayer atIndex:0];
You will probably need to instead set the label on to top of a different UIView: