如何制作支持iOS中所有设备的圆角按钮 [英] How to make round corner button which supports all device in iOS

查看:74
本文介绍了如何制作支持iOS中所有设备的圆角按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的iPhone应用程序中,我有配置文件图片按钮,应该是圆角。总是现在如果我将给角半径一些值,按钮不是在iPhone 6plus中的圆形角落。所以有任何特定的一般方法来使这项工作?
提前致谢...

In my iPhone app i have profile pic button which should be round corner always.Right now if i will give corner radius some value ,button is not round cornered in iPhone 6plus.So is there any specific general way to make this work ? Thanks in advance...

推荐答案

如果按钮的大小(宽度,高度)在所有屏幕中都相同大小然后设置 cornerRadius 一旦应该工作,如果它在不同的屏幕尺寸不同然后做这样的事情,添加按钮作为属性,然后覆盖 viewDidLayoutSubviews 查看控制器类的方法

If size of the button (width, height) are same in all screen sizes then setting cornerRadius once should work, if its different in different screen sizes then do something like this, add button as property and then override viewDidLayoutSubviews method of view controller class

- (void)viewDidLayoutSubviews
{
    [super viewDidLayoutSubviews];
    self.button.layer.cornerRadius = self.button.bounds.size.height / 2;
}

这篇关于如何制作支持iOS中所有设备的圆角按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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