Tuesday, April 10, 2012

Inner shadow effect on UIView layer?


I have the following CALayer:




CAGradientLayer *gradient = [CAGradientLayer layer];
gradient.frame = CGRectMake(8, 57, 296, 30);
gradient.cornerRadius = 3.0f;
gradient.colors = [NSArray arrayWithObjects:(id)[RGB(130, 0, 140) CGColor], (id)[RGB(108, 0, 120) CGColor], nil];
[self.layer insertSublayer:gradient atIndex:0];



I'd like to add an inner shadow effect to it, but I am not quite sure how to do this. I suppose I would be required to draw in drawRect, however this would add the layer on top of other UIView objects, since it's supposed to be a bar behind some buttons, so I am at a loss as to what to do?



I could add another layer, but again, not sure how to achieve the inner shadow effect (like this: http://sublimeorange.com/uploads/2009/09/innershadow.png )



Help appreciated...


Source: Tips4all

No comments:

Post a Comment