Getting a UILabel to appear above a UINavigationBar
self.navigationController.navigationBar.ti开发者_开发技巧ntColor = [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];
This is my code. When I position the UILabel, it won't float over the navigationBar. Is there any way to achieve this?
Add the label as a subview of the navigation bar, not self.view
:
[self.navigationController.navigationBar addSubview:header];
精彩评论