为UIImage制作圆角 [英] Making round corners for a UIImage

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

问题描述

在我的iPhone应用程序中,我必须显示一个UIImage,该UIImage的所有四个角都弯曲,以使其在屏幕上看起来不错。但是我的图像是矩形图像,因为它来自第三方,因此无法在图像级别进行更改。

In my iPhone application I have to show a UIImage with its all four corners curved so that it looks good on the screen. But my image is a rectangular image which cannot be altered at image level as it comes from a third party.

使用UIImageView,我可以设置框架。使用代码,如何修改UIImage使其具有圆角?

With UIImageView I can set the frame. Using code, how can I modify my UIImage to have rounded corners?

任何线索?

推荐答案

尝试这种方式:

UIImageView *imageView = ...;
imageView.layer.cornerRadius = 7; // change this value  as per your desire
imageView.clipsToBounds = YES;

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

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