self.navigationController.navigationBar.tintColor = [UIColor blackColor];
UILabel *header = [[UILabel alloc] initWithFrame:CGRectMake(100, 0, 320, 10)];
header.text = @"Test";
header.textColor = [UIColor brownColor];
header.backgroundColor = [UIColor clearColor];
header.font = [UIFont fontWithName:@"Zapfino" size: 14.0];
[super viewDidLoad];
[self.view addSubview:header];
这是我的代码。当我定位UILabel时,它不会漂浮在navigationBar上。有没有办法实现这个目标?
答案 0 :(得分:2)
将标签添加为导航栏的子视图,而不是self.view
:
[self.navigationController.navigationBar addSubview:header];