Adjusting navigationItem.titleView's frame?

前端 未结 13 1761
小蘑菇
小蘑菇 2021-01-31 04:14

I noticed that the titleView\'s position depends on the rightbarbutton title. How can I set the frame of the titleView to be in the center instead?

I\'ve tried setting

13条回答
  •  渐次进展
    2021-01-31 04:25

    My solution was to manually resize the navigation bar in viewDidAppear:

    - (void)viewDidAppear
    {
         [super viewDidAppear];
         [self.navigationController.navigationBar setFrame:CGRectMake(x, y, width, height)];
    }
    

    ...after that you can reposition the title view as well. I just noticed that the main issue was the fact that the navigation bar wqas resized as well, so I brought it back to its regular size. I got the regular size from debugging and checking its size in viewDidLoad before it got modified...

提交回复
热议问题