Xcode4 获取显示在UINavigationBar上方的UILabel

Xcode4 获取显示在UINavigationBar上方的UILabel,xcode4,Xcode4,这是我的密码。当我定位UILabel时,它不会浮在导航栏上。有什么方法可以实现这一点吗?将标签添加为导航栏的子视图,而不是self.view: self.navigationController.navigationBar.tintColor = [UIColor blackColor]; UILabel *header = [[UILabel alloc] initWithFrame:CGRectMake(100, 0, 320, 10)]; header.text = @"Test"; he

这是我的密码。当我定位UILabel时,它不会浮在导航栏上。有什么方法可以实现这一点吗?

将标签添加为导航栏的子视图,而不是
self.view

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];

很抱歉,3年后才接受此消息,当时我还太小,不知道如何使用stackoverflow。
[self.navigationController.navigationBar addSubview:header];