F.SO4 F.SO4 - 3 months ago 17x
iOS Question

Adding shadow to floating UICollectionView headers

I have an

with 2 sections, each one has its own floating header.

My question is if is there any way to add shadow below the header that will be displayed on the collection's cells?


Make a pointer to your collection view's header. (Info)

Then apply following CALayer? effect:


    yourObject.clipsToBounds = NO;//necessary, dont change
    yourObject.layer.masksToBounds = NO;//necessary, dont change
    yourObject.layer.shadowColor = [[UIColor blackColor] CGColor];//color
    yourObject.layer.shadowOpacity = 0.5f;//translucency (alpha)
    yourObject.layer.shadowRadius = 1.5f;//size | spread
    yourObject.layer.shadowOffset = CGSizeMake(0.0f, 2.5f);//direction (x,y)

Convert to Swift as needed.