UIView shadow not working
If you have to use masksToBounds = YES;
check out this SO post. It tells you how to use both shadows and rounded corners (in this particular case) on a view by using two nested views: the outer view casts the shadow and does not mask to bounds while the inner view has rounded corners and masks to bounds.
The shadow is drawn outside of the layer's bounds. You have to set listView.layer.masksToBounds = NO
to see the shadow
if you set listView.layer.masksToBounds = YES
you can't draw anything out side of bounds so you can not get shadow
Only below worked for me
[self.view bringSubviewToFront:subView];
The shadow is actually drawn below the UIView. If you set maskToBounds to YES, this clips any drawing outside of the UIView frame. Here is a SO link that describes this in more detail.