iOS 清理圆角的个人资料图片 [英] iOS Clean corners for rounded profile image
本文介绍了iOS 清理圆角的个人资料图片的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
所以我遵循了 AppCoda 关于圆角的教程个人资料图片,它工作正常,除了一件事.无论图像被圆角化,图像中都会出现一点渗色(尤其是在使用白色边框的情况下).
So I followed an AppCoda tutorial on rounding the corners of a profile image, and it worked fine, except for one thing. Wherever the image was rounded, there is a bit of bleed-through from the image (especially if a white border is used).
self.imageview.image = image
self.imageview.layer.cornerRadius = 10.0
self.imageview.layer.borderWidth = 3.0
self.imageview.layer.borderColor = UIColor.whiteColor().CGColor
self.imageview.clipsToBounds = true
推荐答案
如果需要,您还可以添加一个稍微嵌入的蒙版:
You can also add a mask which is inset a little, if you want:
let path = UIBezierPath(roundedRect: CGRectInset(imageView.bounds, 0.5, 0.5), cornerRadius: 10.0)
let mask = CAShapeLayer()
mask.path = path.CGPath
imageview.layer.mask = mask
这篇关于iOS 清理圆角的个人资料图片的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文