UINavigationBar title

后端 未结 3 1580
傲寒
傲寒 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:15

    Use this:

      UILabel *label = [[UILabel alloc]init];
      [label setBackgroundColor:[UIColor clearColor]];
      [label setTextColor:[UIColor whiteColor]];
      [label setText:self.title];
      label.adjustsFontSizeToFitWidth=YES;
      label.lineBreakMode=UILineBreakModeWordWrap;
      label.numberOfLines=0;
      [label setFont:[UIFont boldSystemFontOfSize:16.0]];
      [self.navigationController.navigationBar.topItem setTitleView:label];
      [label release];
    
    Hope this will help u..!
    

提交回复
热议问题