开发者

Getting a UILabel to appear above a UINavigationBar

开发者 https://www.devze.com 2023-03-31 15:18 出处:网络
self.navigationController.navigationBar.ti开发者_开发技巧ntColor = [UIColor blackColor]; UILabel *header = [[UILabel alloc] initWithFrame:CGRectMake(100, 0, 320, 10)];
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

精彩评论

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

关注公众号