- 最简单还是还设计师要个图, 四周与背景色一直, 中间透明, 直接覆盖上去即可
- 建一个UIView的category
添加以下方法并声明出去
- (void)setAllCornerWithRoundedCornersSize:(CGFloat)cornersSize {
UIBezierPath *maskPath;
maskPath = [UIBezierPath bezierPathWithRoundedRect:self.bounds cornerRadius:cornersSize];
CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init];
maskLayer.frame = self.bounds;
maskLayer.path = maskPath.CGPath;
self.layer.mask = maskLayer;
}
在cell类中引入刚才这个类, 然后在- (void)layoutSubviews{}方法中用需要裁圆的imageView, 调用这个方法即可, conerSize就是边长的一半
顺便贴个原始方法
_imageViewOfPic.layer.cornerRadius = 40;
_imageViewOfPic.layer.masksToBounds = YES;
调用还是和第二个方法一样
网友评论