Can't add a corner radius and a shadow

Viewed 21329

I'm trying to draw a shadow and a corner radius on an image. I can add them separately, but I've got no way to add both effects at the same time. I'm adding a shadow with:

[layer setShadowOffset:CGSizeMake(0, 3)];
[layer setShadowOpacity:0.4];
[layer setShadowRadius:3.0f];
[layer setShouldRasterize:YES];

Here, layer is a CALayer of a UIView subclass. So this works whenever I set

[layer setMasksToBounds:NO];

Now to add a corner radius I do this:

[layer setCornerRadius:7.0f];

but I need to set MasksToBounds to YES in order for this to work:

[layer setMasksToBounds:YES];

Is there anyway I can get both of these effects to add?

Thanks for your time,

Denis

4 Answers
Related