iOS 7中的导航后退按钮原点

iOS 7中的导航后退按钮原点,ios,iphone,objective-c,uinavigationbar,uinavigationitem,Ios,Iphone,Objective C,Uinavigationbar,Uinavigationitem,我已经创建了自定义的“导航后退”按钮。但iOS 6和iOS 7中按钮的来源不同 iOS 6外观: iOS 7外观: 如何将iOS 7中的导航返回按钮设置为与iOS 6中相同?使用此代码固定左栏按钮位置: //First add the following macro: #define SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(v) ([[[UIDevice currentDevice] systemVersion] compare:v o

我已经创建了自定义的“导航后退”按钮。但iOS 6和iOS 7中按钮的来源不同

iOS 6外观:

iOS 7外观:


如何将iOS 7中的导航返回按钮设置为与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];
    }
试试这个:

#define SYSTEM_VERSION_LESS_THAN(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedAscending)

- (void)setupNavigationButton {
     UIView *backButtonView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, backButtonImage.size.width, backButtonImage.size.height)];
    //Align button left with view
    if (SYSTEM_VERSION_LESS_THAN(@"7")) {
        backButtonView.bounds = CGRectOffset(backButtonView.bounds, -8, -5);
    } else {
        backButtonView.bounds = CGRectOffset(backButtonView.bounds, 2.5, 0);
    }
    [backButtonView addSubview:button];

    UIBarButtonItem *customBarItem = [[UIBarButtonItem alloc] initWithCustomView:backButtonView];
    self.navigationController.navigationItem.leftBarButtonItem = customBarItem;
}

其他人也有类似的问题,也许这些链接可以帮助您[1]:[2]:如何创建
后退按钮