带边框的 iOS 圆角 UIImage [英] iOS rounded corner UIImage with border

查看:40
本文介绍了带边框的 iOS 圆角 UIImage的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法让我的图像看起来像这样(圆角和浅色边框).

Is there a way to make my image appear like this (rounded corners and with a light border).

我正在考虑创建一个中间透明的白色蒙版,可以放在上面,这行得通吗?

I'm thinking of creating a white mask that has the middle transparent to place on top, would that work?

推荐答案

您可以完成此操作,但无需编辑您的 UIImage,只需在您的 UIImageView 中执行此操作即可.

You can accomplish this, but instead of editing your UIImage, just do this in your UIImageView.

首先,添加 QuartzCore 头

First, add the QuartzCore header

#import <QuartzCore/QuartzCore.h>

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

And then, edit the properties below, as you wish.

imageView.layer.cornerRadius = 5.0;
imageView.layer.borderColor = [[UIColor grayColor] CGColor];
imageView.layer.borderWidth = 2.0;
imageView.layer.masksToBounds = YES;

这篇关于带边框的 iOS 圆角 UIImage的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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