UIImageView border 黑边

使用 .cornerRadius 设置圆角边框时,会出现黑色毛边,可以使用下面的方法进行修改
// 添加圆角
CAShapeLayer *circleShape = [CAShapeLayer layer];
circleShape.path = [UIBezierPath bezierPathWithOvalInRect:CGRectMake(0, 0, kWLKKExploreBottomHeadWidth, kWLKKExploreBottomHeadWidth)].CGPath;
imageView.layer.mask = circleShape;
// 添加边距
CAShapeLayer *circleBorder= [CAShapeLayer layer];
circleBorder.path = [UIBezierPath bezierPathWithOvalInRect:CGRectMake(0, 0, kWLKKExploreBottomHeadWidth, kWLKKExploreBottomHeadWidth)].CGPath;
circleBorder.strokeColor = [UIColor hexChangeFloat:@"F9F9F9"].CGColor;
circleBorder.fillColor = [UIColor clearColor].CGColor;
circleBorder.lineWidth = 2.f;
[imageView.layer addSublayer:circleBorder];

你可能感兴趣的:(UIImageView border 黑边)