Skip to main content

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

Comments

Popular posts from this blog

Slow Android emulator

I have a 2.67 GHz Celeron processor, 1.21 GB of RAM on a x86 Windows XP Professional machine. My understanding is that the Android emulator should start fairly quickly on such a machine, but for me it does not. I have followed all instructions in setting up the IDE, SDKs, JDKs and such and have had some success in staring the emulator quickly but is very particulary. How can I, if possible, fix this problem?