转自:http://www.jianshu.com/p/2df0ea05c005
- (void)collectionView:(UICollectionView *)collectionView willDisplayCell:(UICollectionViewCell *)cell forItemAtIndexPath:(NSIndexPath *)indexPath
{
CGRect cellBounds = CGRectMake(0, 0, cellWidth, cellHeight);
CAShapeLayer *maskLayer = [CAShapeLayer layer];
maskLayer.frame = cellBounds;
UIBezierPath *bezierPath = [UIBezierPath bezierPathWithRoundedRect:cellBounds cornerRadius:cornerRadius];
maskLayer.path = bezierPath.CGPath;
[cell.layer setMask:maskLayer];
}