iOS清洁圆角轮廓图像的角落 [英] iOS Clean corners for rounded profile image

查看:130
本文介绍了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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆