iOS圆角UIImage带边框

Jam*_* Gu 5 uiimageview uiimage ios

有没有办法让我的图像看起来像这样(圆角和浅边框).在此输入图像描述

我正在考虑创建一个中间透明的白色面具放在上面,这会起作用吗?

Luc*_*rdo 18

你可以做到这一点,但不是编辑你的UIImage,而是在UIImageView中执行此操作.

首先,添加QuartzCore标头

#import <QuartzCore/QuartzCore.h>
Run Code Online (Sandbox Code Playgroud)

然后,根据需要编辑下面的属性.

imageView.layer.cornerRadius = 5.0;
imageView.layer.borderColor = [[UIColor grayColor] CGColor];
imageView.layer.borderWidth = 2.0;
imageView.layer.masksToBounds = YES;
Run Code Online (Sandbox Code Playgroud)


Dan*_*Dan 0

您需要查看QuartzCore 文档,特别是 CALayer 中的cornerRadius、borderColor 和 borderWidth 属性。