iOS清洁圆角轮廓图像的角落

mgi*_*inn 2 uiview ios

所以我按照AppCoda教程对圆形图像的角落进行了四舍五入,除了一件事之外,它工作得很好.无论图像是圆形的,图像都会有一些渗透(特别是如果使用白色边框).

在此输入图像描述

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
Run Code Online (Sandbox Code Playgroud)

在此输入图像描述

Rob*_*Rob 6

如果你愿意,你也可以添加一个插入的面具:

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
Run Code Online (Sandbox Code Playgroud)