I have created custom UINavigation Back Button
. But the origin of the button is different in iOS 6 and iOS 7.
iOS 6 look:
iOS 7 look:
How to set UINavigation Back Button
origin in iOS 7 to be the same like in iOS 6?
I have created custom UINavigation Back Button
. But the origin of the button is different in iOS 6 and iOS 7.
iOS 6 look:
iOS 7 look:
How to set UINavigation Back Button
origin in iOS 7 to be the same like in iOS 6?
Use this code to fix left bar button position:
//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];
}
Try this:
#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;
}