如何在iOS 7.1中影响通过辅助功能设置启用的按钮形状的外观? [英] How can the appearance of Button Shapes enabled through the Accessibility settings be influenced in iOS 7.1?

查看:127
本文介绍了如何在iOS 7.1中影响通过辅助功能设置启用的按钮形状的外观?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

The release of iOS 7.1 brings the availability of Button Shapes under the Accessibility settings. I've noticed that their appearance can be inconsistent within my app. Mostly, I'm getting a black background after having implemented a UIBarButtonItem using Interface Builder. Touching the button but not fully tapping it results in the image turning gray. How can the appearance of the button shapes be influenced so that they will not look so out of place as having a solid black background and more like the gray background as shown in the attached image? In this case I do not want to use a custom control.

推荐答案

此功能似乎在iOS 7.1中有点小问题。似乎影响外观最多的设置实际上是 UINavigationBar 上的 barTintColor

This feature seems to be a little buggy in iOS 7.1. The setting that seems to influence the appearance the most is actually the barTintColor on your UINavigationBar.

一些例子:

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

    return YES;
}

首次启动时,后退按钮看起来不错:

When I first launch, the back button looks fine:

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

Then when I go to landscape, it looks way too dark:

当我回到肖像时它会变得太暗:

And it then stays too dark when I go back to portrait:

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

The same thing happens when I use [UIColor orangeColor] as the barTintColor. First it`s fine:

在风景中它搞砸了:

然后它保持这种状态:

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

So it clearly looks like a bug in iOS 7.1. One thing that can be done is to set a background image for the back button. This background will then display whether "Button Shapes" is activated or not. Example:

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

So the big question is: Can we set the button background image when "Button Shapes" is turned on in a way that is independent of the barTintColor?

这篇关于如何在iOS 7.1中影响通过辅助功能设置启用的按钮形状的外观?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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