开发者

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

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜