I have found an another solution for it, Instead of adding shape layer to each UICollectionViewCell
, I have added the shape layer to the whole UICollectionView
by using [UIBezierPath bezierPathWithArcCenter:radius:startAngle:endAngle:clockwise:]
.
I have used the code mentioned below
-(UICollectionView *)roundCornersOnView:(UICollectionView *)view{
UICollectionView *roundedView = view;
UIBezierPath *maskPath ;
maskPath=[UIBezierPath bezierPathWithArcCenter:CGPointMake(160, 350) radius:350 startAngle:0 endAngle:1.5708 clockwise:NO];
CAShapeLayer *maskLayer = [CAShapeLayer layer];
maskLayer.frame = roundedView.bounds;
maskLayer.path = maskPath.CGPath;
roundedView.layer.mask = maskLayer;
return roundedView;
}