美文网首页
UIImageView border 黑边

UIImageView border 黑边

作者: ReidWang | 来源:发表于2019-05-05 15:25 被阅读0次

    使用 .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 黑边

          本文链接:https://www.haomeiwen.com/subject/qqhhoqtx.html