IOS7 UIButton仅显示文本

IOS7 UIButton仅显示文本,ios,ios7,uibutton,Ios,Ios7,Uibutton,我在视图上有一个普通的UIButton,当我在IOS6模拟器中启动应用程序时,我看到一个带有文本的按钮。当我在IOS7模拟器下启动同一个应用程序时,我看到的只是下面没有按钮的文本 它在XCode中看起来是正确的: 但这是我在IOS7模拟器中看到的: 这就是iOS 7系统按钮的外观。 如果要模拟iOS 6外观,请将其更改为自定义按钮,设置自己的背景,然后执行以下操作: 首先将导入框架添加到.m文件中,并对按钮使用以下代码 button.layer.cornerRadius = 4; button.

我在视图上有一个普通的UIButton,当我在IOS6模拟器中启动应用程序时,我看到一个带有文本的按钮。当我在IOS7模拟器下启动同一个应用程序时,我看到的只是下面没有按钮的文本

它在XCode中看起来是正确的:

但这是我在IOS7模拟器中看到的:

这就是iOS 7系统按钮的外观。 如果要模拟iOS 6外观,请将其更改为自定义按钮,设置自己的背景,然后执行以下操作:

首先将导入框架添加到.m文件中,并对按钮使用以下代码

button.layer.cornerRadius = 4;
button.clipToBounds = YES;
button.layer.borderColor = [UIColor {your color here}].CGColor;
button.layer.borderWidth = 1;
// Set button background color as white color ...

[yourbutton.layer setBorderColor:[[UIColor ClearColor] CGColor]];
[yourbutton.layer setBorderWidth:0.0];
[yourbutton.layer setCornerRadius:10.0f];
[yourbutton.layer setMasksToBounds:YES];

这是iOS 7中的新按钮样式。你看到的是正常的。如果您想在iOS 6和iOS 7上拥有一致的风格,您需要将buttonType设置为Custom(自定义),我想现在是系统,选择颜色等。

这是iOS 7中的默认外观按钮。 只是文字-没有背景


如果你真的想看到按钮的轮廓,你必须添加自己的背景图像。

这就是ios 6和ios 7的区别。如果你想像ios 6一样,你必须进行定制

如果您想喜欢ios 6,请遵循以下代码:

首先将导入框架添加到.m文件中,并对按钮使用以下代码

button.layer.cornerRadius = 4;
button.clipToBounds = YES;
button.layer.borderColor = [UIColor {your color here}].CGColor;
button.layer.borderWidth = 1;
// Set button background color as white color ...

[yourbutton.layer setBorderColor:[[UIColor ClearColor] CGColor]];
[yourbutton.layer setBorderWidth:0.0];
[yourbutton.layer setCornerRadius:10.0f];
[yourbutton.layer setMasksToBounds:YES];

易于理解的iOS 7下的按钮与iOS 6下的按钮看起来不同。你所看到的是正确的。在开始开发之前,你有没有看过iOS?谢谢你的支持。我添加了dButton.layer.backgroundColor=[UIColor-whiteColor].CGColor;也谢谢你的支持