How can I get a full-sized UINavigationBar titleView

前端 未结 6 1573
遇见更好的自我
遇见更好的自我 2020-12-25 14:25

I am trying to add a custom control as the titleView in a UINavigationBar. When I do so, despite setting the frame and the properties that would normally assume full width,

6条回答
  •  一整个雨季
    2020-12-25 14:57

    CGRect frame = CGRectMake(0, 0, 320, 44);

    UILabel *titlelabel = [[UILabel alloc]initWithFrame:frame];
    
    titlelabel.textAlignment = UITextAlignmentCenter;
    
    titlelabel.backgroundColor = [UIColor clearColor];
    
    titlelabel.textColor = [UIColor whiteColor];
    
    titlelabel.font = [UIFont systemFontOfSize:20];
    
    titlelabel.text =@"Available Reports";
    
    self.navigationItem.titleView = titlelabel;
    

    if you want to set image then take uiimage view instead on uilable you can create any view of fully navigation bar just tell me how ur navigation look like i will send you code for that if you want i can put 6 button on navigation also

提交回复
热议问题