我已经创建了自定义 UINavigation 后退按钮
。但是按钮的来源在 iOS 6 和 iOS 7 中是不同的。
iOS 6 外观:
iOS 7 外观:
如何将 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/