I need to add a bottom shadow my collection view,here is my code:
weakself!.layer.shadowPath = UIBezierPath(rect: weakself!.bounds).CGPath
weakself!.layer.masksToBounds = false
weakself!.layer.shadowOffset = CGSizeMake(0.0, 3.0);
weakself!.layer.shadowColor = UIColor.blackColor().CGColor
weakself!.layer.shadowOpacity = 0.5
the above code is work perfect with other views. but it make the collection view to scroll above it's bounds. as you can see here in the bellow picture where the collection view scroll above the search bar:
If you need to do this you should add the collection view to a plain view, don't change the collection view, add the shadow to the plain view (the collections views superview).
I'd really recommend not using a shadow but instead presenting the collection as a popover or at least with a full screen backing view which dimmed the background and made the collection view more obvious (and prevented taps on other things like the partially visible buttons).