Created
December 22, 2016 17:23
-
-
Save nor0x/076cef18b1e412d2f432da911b9a5bab to your computer and use it in GitHub Desktop.
UICollectionViewCell -> Corner Radius AND Shadow
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { | |
cell.contentView.layer.cornerRadius = 2.0 | |
cell.contentView.layer.borderWidth = 1.0 | |
cell.contentView.layer.borderColor = UIColor.clear.cgColor | |
cell.contentView.layer.masksToBounds = true; | |
cell.layer.shadowColor = UIColor.lightGray.cgColor | |
cell.layer.shadowOffset = CGSize(width:0,height: 2.0) | |
cell.layer.shadowRadius = 2.0 | |
cell.layer.shadowOpacity = 1.0 | |
cell.layer.masksToBounds = false; | |
cell.layer.shadowPath = UIBezierPath(roundedRect:cell.bounds, cornerRadius:cell.contentView.layer.cornerRadius).cgPath | |
return cell | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks. its working fine.