Can I change the position of navigationbar item?

前端 未结 7 912
无人共我
无人共我 2021-01-31 18:57

Here is the snapshot: \"enter

And the code is here:

UIButton *leftButton =         


        
7条回答
  •  攒了一身酷
    2021-01-31 19:50

    You need to create a UIBarButtonItem with system item UIBarButtonSystemItemFixedSpace with -5 width which will remove 5 px padding. Then set leftBarButtonItems with both fixed space item and your back bar item like this -

    UIBarButtonItem *negativeSpacer = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFixedSpace target:nil action:nil];
    [negativeSpacer setWidth:-5];
    
    self.navigationItem.leftBarButtonItems = [NSArray arrayWithObjects:negativeSpacer,leftBarItem,nil];
    

提交回复
热议问题