UIBarButtonItem setTitlePositionAdjustment on iOS 7 Navigation Bar

I have a UINavigationBar that has a new height of 85 and is fixed for landscape and portrait. I add an edit button in the upper right corner, but it will not stay there.

I used the following:

 [item setTitlePositionAdjustment:UIOffsetMake(0, -47) forBarMetrics:UIBarMetricsDefault]; 

But, if I rotate the device, it moves down 47 to its original location. If I change the metrics again, it will return to its original location. If I replace the button with another button, it will move the new button to its original location, and setting the position for the new button will do nothing.

I can’t figure out how to move the button and make it stay. Cannot use restrictions for UIBarButtonItem .

+6
source share
1 answer

You can try putting a UIView in the upper right corner as a child of the UINavigationBar . Set the UIView to the same height as the navigation bar, and put your button in the view. Then you can add restrictions to the button inside the view.

0
source

All Articles