ios - 在 iOS 7.1 中如何影响通过辅助功能设置启用的按钮形状的外观?

标签 ios ios7.1

enter image description here

iOS 7.1 的发布在辅助功能设置下提供了按钮形状。我注意到它们的外观在我的应用程序中可能不一致。大多数情况下,在使用 Interface Builder 实现 UIBarButtonItem 后,我得到了黑色背景。触摸按钮但未完全点击它会导致图像变灰。如何影响按钮形状的外观,使它们看起来不会像具有纯黑色背景那样不合时宜,更像是附图中所示的灰色背景?在这种情况下,我不想使用自定义控件。

最佳答案

这个功能在 iOS 7.1 中似乎有点问题。似乎对外观影响最大的设置实际上是 UINavigationBar 上的 barTintColor

一些例子:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    [[UINavigationBar appearance] setBarTintColor:[UIColor lightGrayColor]];

    return YES;
}

当我第一次启动时,后退按钮看起来不错:

enter image description here

然后当我去风景时,它看起来太暗了:

enter image description here

当我回到纵向时,它仍然太暗:

enter image description here

当我使用 [UIColor orangeColor] 作为 barTintColor 时,同样的事情发生了。 首先它很好:

enter image description here

在景观中它变得困惑:

enter image description here

然后它就这样了:

enter image description here

所以它显然看起来像是 iOS 7.1 中的一个错误。可以做的一件事是为后退按钮设置背景图像。然后这个背景将显示“按钮形状”是否被激活。示例:

UIImage *backButtonImage = [[UIImage imageNamed:@"back_button.png"] resizableImageWithCapInsets:UIEdgeInsetsMake(0.0f, 17.0f, 0.0f, 1.0f) resizingMode:UIImageResizingModeStretch];

[[UIBarButtonItem appearance] setBackButtonBackgroundImage:backButtonImage forState:UIControlStateNormal barMetrics:UIBarMetricsDefault];
[[UIBarButtonItem appearance] setBackButtonBackgroundImage:backButtonImage forState:UIControlStateHighlighted barMetrics:UIBarMetricsDefault];

[[UIBarButtonItem appearance] setBackButtonBackgroundImage:backButtonImage forState:UIControlStateNormal barMetrics:UIBarMetricsLandscapePhone];
[[UIBarButtonItem appearance] setBackButtonBackgroundImage:backButtonImage forState:UIControlStateHighlighted barMetrics:UIBarMetricsLandscapePhone];

所以最大的问题是:当“按钮形状”打开时,我们能否以一种独立于 barTintColor 的方式设置按钮背景图像?

关于ios - 在 iOS 7.1 中如何影响通过辅助功能设置启用的按钮形状的外观?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22373815/

相关文章:

IOS MDM 许可证和 SSl 证书(测试)

ios - iOS 7.1 中的 SDWebImage 崩溃

swift - RTF 文件到属性字符串

java - 在客户端应用程序中声明 REST 服务 api 端点的正确模式?

iphone - 使用当前时间以编程方式添加 UILabel

ios - 角标(Badge)显示在 UIButton 后面

UIAlertController/UIAlertView 的 iOS/Swift 测试

objective-c - 如何在横向和纵向隐藏主视图 UISplitViewController iOS7.1

ios - 是否可以在受控环境中从浏览器获取 iOS 设备的唯一标识符?

ios - 首次加载时 SDWebImage 单元格 ImageView 大小错误