我遇到了这个问题,在 iOS 7 上该应用程序运行正常:
在 iOS 6.1 上,该栏不起作用。空间错误,按钮位置和所有对象显示在错误的位置。
最佳答案
从 iOS7 开始,状态栏发生了很大变化 - 您可以在这里阅读:https://developer.apple.com/library/ios/documentation/UserExperience/Conceptual/MobileHIG/Bars.html#//apple_ref/doc/uid/TP40006556-CH12-SW1
更好的问题是 - 您希望状态栏在 iOS 6.1 上表现如何? 关于左栏按钮项,为了使 iOS6.1 按钮看起来像 iOS7.0 按钮,您必须创建一个自定义按钮 - 这是可以完成的。例如创建一个类似于 iOS7 的箭头图像(我在下面的代码中将其称为“back_arrow.png”),如果需要看起来像 iOS7.0 按钮,请编写以下内容(在编写以下内容之前检查 iOS 版本,编写仅适用于iOS版本<7.0)
UIImage * backButtonImage = [UIImage imageNamed: @"back_arrow.png"];
[[UIBarButtonItem appearance] setBackButtonBackgroundImage: backButtonImage forState: UIControlStateNormal barMetrics: UIBarMetricsDefaultPrompt];
[[UIBarButtonItem appearance] setBackButtonBackgroundImage: backButtonImage forState: UIControlStateNormal barMetrics: UIBarMetricsDefaultPrompt];
NSDictionary *attributes = [NSDictionary dictionaryWithObjectsAndKeys:
[UIColor clearColor],
UITextAttributeTextColor,
[UIFont fontWithName:@"HelveticaNeue-Bold" size:14],
UITextAttributeFont,
[UIColor colorWithRed:70.0/255.0 green:120.0/255.0 blue:251.0/255.0 alpha:1.0],
UITextAttributeTextShadowColor, nil];
NSDictionary *highlightedAttributes = [NSDictionary dictionaryWithObjectsAndKeys:
[UIColor clearColor],
UITextAttributeTextColor,
[UIFont fontWithName:@"HelveticaNeue-Bold" size:14],
UITextAttributeFont,
[UIColor colorWithRed:70.0/255.0 green:120.0/255.0 blue:251.0/255.0 alpha:0.7],
UITextAttributeTextShadowColor, nil];
[[UIBarButtonItem appearance] setTitleTextAttributes: attributes
forState: UIControlStateNormal];
[[UIBarButtonItem appearance] setTitleTextAttributes: highlightedAttributes
forState: UIControlStateHighlighted];
[[UIBarButtonItem appearance] setBackButtonTitlePositionAdjustment:UIOffsetMake(0,0) forBarMetrics:UIBarMetricsDefaultPrompt];
关于ios - UINavigationController 在 iOS7 上无法像在 iOS6.1 上一样同时工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19416469/