ios - iOS 7 中的 UINavigation 后退按钮起源

标签 ios iphone objective-c uinavigationbar uinavigationitem

我已经创建了自定义 UINavigation 后退按钮。但是按钮的来源在 iOS 6 和 iOS 7 中是不同的。

iOS 6 外观:

enter image description here

iOS 7 外观:

enter image description here

如何将 iOS 7 中的 UINavigation Back Button origin 设置为与 iOS 6 中的相同?

最佳答案

使用此代码修复左侧栏按钮的位置:

    //First add the following macro:
    #define SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedAscending)

    //Then customize your navigation bar:
    - (void) initNavigationBar
    {
        UIBarButtonItem *negativeSpacer = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFixedSpace target:nil action:nil];
        if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"7.0"))
        {
            negativeSpacer.width = -10;
        }
        else
        {
            negativeSpacer.width = 0;
        }

        UIBarButtonItem *backButton = [[UIBarButtonItem alloc] initWithCustomView:_customBackButton];
        self.navigationItem.leftBarButtonItems = @[negativeSpacer,backButton];
    }

关于ios - iOS 7 中的 UINavigation 后退按钮起源,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22528195/

相关文章:

iphone - 从枚举类型 'UIInterfaceOrientation' 到不同枚举类型 'UIDeviceOrientation' 的隐式转换

ios - 继承框架的ViewController类

iphone - 仅在存档时使用 iPhone Target 进行部署

objective-c - 为什么我的NSArray被释放?

ios - 标题以编程方式在 iOS 7 中的 UITabBarController 中显示更大

iphone - 我担心 arc4random 背叛了我

iOS:使用 AFNetworking 解析 JSON 并检索特定信息?

ios - 通过指针解析排序查询

ios - 函数产生预期类型 '(() -> ())?' ;你的意思是用 '()' 来调用它吗?

ios - 本地化 LaunchImage