Monday, May 6, 2013

Adding Gradient effect to UILabel color


Below is the code snippet which when added to ur code will give a gradient effect to the UILabel. The output will be similar to the gradient effect in the UINavigationBar.


CAGradientLayer*gradient =[CAGradientLayer layer];
 gradient.frame = myView.bounds;//view fo the object whose graidient u are to set.
 gradient.colors =[NSArray arrayWithObjects:(id)[[UIColor blackColor]CGColor],(id)
                                [[UIColor whiteColor]CGColor], nil];
[myView.layer insertSublayer:gradient atIndex:0];


No comments:

Post a Comment