我想知道如何在使用UINavigationController时更改视图标题的字体大小.., 提前致谢
答案 0 :(得分:1)
您无法直接更改它。使用您想要的样式创建自定义UILabel
或任何其他视图,并将其指定为self.navigationItem.titleView
。
答案 1 :(得分:1)
self.title = @"";
UILabel *myNavigationTitleLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 5, self.view.frame.size.width, 33)];
myNavigationTitleLabel.textColor = [UIColor whiteColor];
myNavigationTitleLabel.backgroundColor = [UIColor clearColor];
myNavigationTitleLabel.text = @"my Custom title";
myNavigationTitleLabel.textAlignment = UITextAlignmentCenter;
myNavigationTitleLabel.font = [UIFont fontWithName:@"Arial" size:17];
[self.navigationController.navigationBar addSubview:myNavigationTitleLabel];
[myNavigationTitleLabel release];
请注意,如果您有横向界面方向,则需要为myNavigationTitleLabel设置新框架。
答案 2 :(得分:0)
更改字体和标题...
+(void)setNavigationTitle:(NSString *)title ForNavigationItem:(UINavigationItem *)navigationItem { UIView * view = [[UIView alloc] initWithFrame:CGRectMake(0.0f, 0.0f,200.0f,44.0f)];
UILabel *titleLbl = [[UILabel alloc]
initWithFrame:CGRectMake(0.0f,6.0f,200.0f,30.0f)];
[titleLbl setFont:[UIFont fontWithName:@"BellCent NamNum BT"
尺寸:24.0]];
[titleLbl setBackgroundColor:[UIColor clearColor]]; [titleLbl setTextAlignment:UITextAlignmentCenter]; [titleLbl setTextColor:UIColorFromRedGreenBlue(35,134,192)]; [titleLbl setShadowColor:UIColorFromRedGreenBlue(186,186,186)]; [titleLbl setShadowOffset:CGSizeMake(1.0f, 1.0f)]; [titleLbl setText:title]; [view addSubview:titleLbl]; [navigationItem setTitleView:view]; [titleLbl release]; }