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/

相关文章:

xcode - Sprite Kit iOS 7.1 在 removeFromParent 上崩溃

ios - 显示和关闭 View Controller 后,iOS 7.1 上的标签栏背景丢失

ios - 将 @IBSegueAction 与 UINavigationController 一起使用

ios - 'SchemaMetadata' 不是 'Self.Schema' 类型的成员类型

ios - 无法在 iOS 模拟器上通过 Google 登录

ios - 以编程方式显示 UIButton

ios - 引用项目在 viewDidLoad 中安全地初始化

ios - 运行异步生成的代码块, 'only' 当特定 View Controller 可见并受控制时

ios7.1:推送通知角标(Badge)更新问题

ios - 禁用连接警报(多点连接)