Mar*_*ski 6 uinavigationbar ios
当我从iOS应用程序的开始屏幕推送新的tableViewController时(我按下"设置"屏幕),UINavigationController中的标题将被剪切,直到动画结束:

这是动画中期的NavigationBar,就在动画结束之前,它看起来像这样:

片刻之后,标题会正确更改为"设置".这不是什么大不了的事,但是你可以想象它会让一个稍微喜欢OCD的程序员烦恼多少!:)
这是tableViewController中我设置标题的代码,没什么特别的:
- (id)initWithStyle:(UITableViewStyle)style
{
self = [super initWithStyle:style];
if (self) {
self.title = @"Settings";
// Hide tabBar when pushed so you cannot switch from the Settings
self.hidesBottomBarWhenPushed = YES;
self.tableView.backgroundColor = [UIColor colorWithPatternImage: [UIImage imageNamed:@"bg.png"]];
}
return self;
}
Run Code Online (Sandbox Code Playgroud)
小智 1
我的答案有点晚了,但我在 iOS 5 上找到了这个问题。当您在 UINavigationBar 上使用 UIAppearance 代理时,似乎您需要显式设置字体大小,而不是使用 0.0 让它自动设置基于方向。
我可以通过子类化 UINavigationController 并输入以下代码来解决此问题:
- (void)viewWillLayoutSubviews {
[super viewWillLayoutSubviews];
// You should include a conditional here to check for iOS 5, so iOS 6 doesn't have to do any additional work
self.navigationBar.titleTextAttributes = @{
UITextAttributeFont:[UIFont boldSystemFontOfSize:UIInterfaceOrientationIsPortrait(self.interfaceOrientation) || IS_IPAD ? 20.0f : 16.0f],
UITextAttributeTextColor:[UIColor whiteColor],
UITextAttributeTextShadowColor:[UIColor colorWithWhite:0.0f alpha:0.5f],
UITextAttributeTextShadowOffset:[NSValue valueWithUIOffset:UIOffsetMake(0.0f, -1.0f)]
};
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
794 次 |
| 最近记录: |