user916367
user916367

Reputation:

Getting a UILabel to appear above a UINavigationBar

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

This is my code. When I position the UILabel, it won't float over the navigationBar. Is there any way to achieve this?

Upvotes: 1

Views: 251

Answers (1)

Chaitanya Gupta
Chaitanya Gupta

Reputation: 4053

Add the label as a subview of the navigation bar, not self.view:

[self.navigationController.navigationBar addSubview:header];

Upvotes: 2

Related Questions