[英]put title for NavigationBar
我有以下几点:
头文件 :
UINavigationBar *navigationBar;
UINavigationItem *navigationItem;
实现文件 :在viewDidLoad
方法中,我尝试了以下操作:
self.navigationBar.topItem.title = @"title text";
还有这个:
self.navigationItem.title = @"MyTitle";
[self.navigationBar pushNavigationItem:navigationItem animated:NO];
但是黑色标题栏上似乎没有标题:
您应该在类属性中定义:
@property (nonatomic, assign) IBOutlet UINavigationBar *navigationBar;
您应该将该类设置为File's Owner
。
self.navigationBar.topItem.title = @"title text";
设置其标题: self.navigationBar.topItem.title = @"title text";
尝试这个:-
UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 320, 30)];
label.font = [UIFont boldSystemFontOfSize:14.0];
label.shadowColor = [UIColor colorWithWhite:0.0 alpha:0.5];
label.backgroundColor = [UIColor clearColor];
label.textAlignment = UITextAlignmentCenter;
label.textColor = [UIColor whiteColor];
self.navigationItem.titleView = label;
label.text = [dataItem objectForKey:@"title"];
[label release];
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.