Extraction of shadow of UIView beyond viewing frames

I have a requirement when I need to draw a shadow of a view outside the view frame. We already have a complex hierarchy / hierarchy of views, and now it would be impossible to change the frames of the view and layout to place the shadows within the visibility of the viewController.

1. I am a little worried about whether I can allow the shadow to be drawn outside the view , following this methodology:

"You can also create a shadow, which will be based on the alpha component of what is drawn in your view. Often this will lead to a shadow only at the edges of the view. This is a sample UILabel code:

label.layer.shadowColor = [UIColor blackColor].CGColor;
label.layer.shadowOpacity = 1.0;
label.layer.shadowRadius = 5.0;
label.layer.shadowOffset = CGSizeMake(0, 3);
label.clipsToBounds = NO;

In this case, you need clipToBounds to be NO, so that the shadow outside the frame of your view is displayed. Next Ill will show you how you can combine rounded corners and shadows, since I'm sure you really want to now. "

Link: http://bynomial.com/blog/?p=52

2. Now I came across threads that say that drawing shadow outside the view is not recommended. But no explanation: How to draw a shadow outside of a UIView?

Is there a reason why we should not paint the appearance of shadows (CALayer)? Or is it good after the first approach?

Thanks Raj

+5
source share
1 answer

, , , . " " ? clipsToBounds .

+6

All Articles