1

There are a lot of questions about how to draw a drop shadow for a view. But how can I have my view cast a shadow that is received only by one other view?

pasawaya
  • 11,515
  • 7
  • 53
  • 92
Cornelius
  • 4,214
  • 3
  • 36
  • 55

2 Answers2

0
  • Make an app with a white background.
  • Make your view plus shadow.
  • Take a screen shot.
  • Use the screen shot in your original app.

Of course you could also make the picture on the fly in code, but that is a bit more challenging. In any case, it would be code you do not need in your final app.

Mundi
  • 79,884
  • 17
  • 117
  • 140
0

If view A is the view with the shadow and view B is the parent of A, you can set masksToBounds which is a property of B's layer to YES.

Contents of B and its subviews will not be shown outside of B. They will be clipped.

More detail here: What UIView layer.masksToBounds is doing if set to YES?

However, if you want the shadow drops on more complex scene, you might need to be a little more specific.

Community
  • 1
  • 1
BiGGA
  • 358
  • 2
  • 5