我有这个问题,在iOS 7上该应用程序运行良好:
在iOS 6.1上,该栏无效。空间错误,按钮位置和所有对象显示在错误的位置。
答案 0 :(得分:2)
状态栏从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];