UINavigationBar title

后端 未结 3 1547
傲寒
傲寒 2021-01-15 01:36

I am trying to use a UILabel to replace the title at the UINavigationBar, the code is as follows:

UINavigationBar *bar = [self.navigationController navigatio         


        
3条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-01-15 02:27

    Why don't you just do self.title = @""?

    EDIT: Try this?

    UINavigationBar *bar = [self.navigationController navigationBar];
    [bar setBackgroundColor:[UIColor blackColor]];
    
    UILabel * nav_title = [[UILabel alloc] initWithFrame:CGRectMake(80, 2, 220, 25)];
    nav_title.font = [UIFont fontWithName:@"Arial-BoldMT" size:18];
    nav_title.textColor = [UIColor whiteColor];
    nav_title.adjustsFontSizeToFitWidth = YES;
    nav_title.text = title;
    self.title = @"";
    nav_title.backgroundColor = [UIColor clearColor];
    [bar addSubview:nav_title];
    [nav_title release];
    

提交回复
热议问题