Wednesday, 16 October 2013

Custom Gradient View

Custom Gradient Effect In View [ Iphone]

To give gradient effect to perticuler view we are using here CAGradientLayer
Compatibility:From ios 3.0 and later
1> First to use CAGradientLayer you have to import QuartzCore Framework.
2> To add gradient effect to peticuler view you can use this code:
  CAGradientLayer *gradient = [CAGradientLayer layer];
  gradient.frame = self.viewPopOver.bounds;
   gradient.colors = [NSArray arrayWithObjects:(id)[[UIColor colorWithRed:67.0/255 green:105.0/255    blue:142.0/255 alpha:1] CGColor], (id)[[UIColor colorWithRed:34.0/255 green:69.0/255     blue:108.0/255 alpha:1] CGColor], nil];
    [self.view.layer insertSublayer:gradient atIndex:0];
 The result will be as shown below:

Image

No comments:

Post a Comment