按钮在6.1与7.0中的表现不同

时间:2013-10-18 13:38:28

标签: iphone ios ios7 rubymotion ios6.1

我有以下代码来显示一个简单的按钮:

button = UIButton.buttonWithType(UIButtonTypeRoundedRect)
button.center = CGPointZero
button.frame = [[container.width/2-button.frame.size.width/2,150], [280,50]]
button.setTitle("Categorize New Project", forState: UIControlStateNormal)
button.addTarget(self, 
                 action: "moveToChildView:",
                 forControlEvents: UIControlEventTouchUpInside)

当我在带有6.1的模拟器iPhone视网膜(3.5英寸)中运行此应用程序时,它看起来像这样:

enter image description here

然而,当我在模拟器iPhone视网膜7.0中运行它时,它看起来像这样:

enter image description here

此代码是否需要更改才能与7.0一起使用?

2 个答案:

答案 0 :(得分:6)

从iOS 7开始,默认的圆角矩形按钮如下所示。请参阅UI transition guide。我建议使用自定义按钮来防止版本之间出现这种差异。

答案 1 :(得分:1)

正如Alexander所说它是iOS7的新面貌,他还建议使用自定义按钮,which is good advice
但是这里还有另一种解决这个问题的方法,可以让你输出更低的输出 enter image description here

使用此代码

self.myButton.layer.cornerRadius = 10;
self.myButton.backgroundColor = [UIColor whiteColor];
self.myButton.layer.borderWidth = 1.0f;
相关问题