ios - UINavigationController 在 iOS7 上无法像在 iOS6.1 上一样同时工作

标签 ios uinavigationcontroller position ios7 ios6.1

我遇到了这个问题,在 iOS 7 上该应用程序运行正常:

enter image description here

在 iOS 6.1 上,该栏不起作用。空间错误,按钮位置和所有对象显示在错误的位置。

enter image description here

最佳答案

从 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/

相关文章:

ios - 尝试加载 Storyboard时出错

iphone - 新手 : Errors in an iPhone app

ios - 带有 JSQMessages 的导航栏?

iphone - 如何更改uinavigationbar背景颜色而不覆盖drawRect :

java - 如何在sharedPrefs中保存 View 位置..?

ios - 填充后无法描边路径

ios - dequeueReusableCell 方法返回新的或可重用的对象?

objective-c - 如何在显示搜索栏时将 tableView 的编辑按钮放在工具栏中(如在 Apple 的邮件应用程序中)?

javascript - 相对于其父级位置重新定位 Sprite

javascript - 找到 HTML 元素和浏览器(或窗口)边之间的距离