如何在iPhone中的UI图像中设置圆角 [英] How to set round corners in UI images in iphone

查看:117
本文介绍了如何在iPhone中的UI图像中设置圆角的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试开发一个iPhone应用程序来设置UI Image。

I am trying to develop an iPhone application to set the UI Image.

推荐答案

你无法设置 UIImage 实例,因为它不是从 UIView 继承的,
所以你需要创建一个通过传递 UIImage 来实现UIImageView 实例。

You could not set the corner of UIImage instance because it's not inherited from UIView, So you need to create an UIImageView instance by passing your UIImage.

使用下面的代码。

UIImageView * roundedView = [[UIImageView alloc] initWithImage: [UIImage imageNamed:@"wood.jpg"]];
// Get the Layer of any view
CALayer * l = [roundedView layer];
[l setMasksToBounds:YES];
[l setCornerRadius:10.0];

这篇关于如何在iPhone中的UI图像中设置圆角的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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