我已经创建了自定义导航 Controller ,
我想添加一个,左边是日期,右边是后退按钮,后退按钮旁边是标题。
我试图添加一个标签,但是它不起作用。请给我指路
UINavigationBar *naviBarObj = [[UINavigationBar alloc] initWithFrame:CGRectMake(0, 0, 1024, 66)];
UILabel *navLabel = [[UILabel alloc] initWithFrame:CGRectMake(20,8,280,30)];
navLabel.text = @"My Text";
[self.navigationController.navigationBar addSubview:navLabel];
[self.view addSubview:naviBarObj];
最佳答案
UINavigationBar *naviBarObj = [[UINavigationBar alloc] initWithFrame:CGRectMake(0, 0, 1024, 66)];
UILabel *navLabel = [[UILabel alloc] initWithFrame:CGRectMake(200,8,200,30)];
navLabel.text = @"My Text";
navLabel.textColor = [UIColor redColor];
[naviBarObj addSubview:navLabel];
[navLabel setBackgroundColor:[UIColor clearColor]];
[self.view addSubview:naviBarObj];
尝试一下,它会工作。对我有用:)
关于ios - 在iOS的导航栏上放置标签,按钮,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/17611147/