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?
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.
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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.