问题
Is it possible to reposition a UIBarButtonItem that's in a UINavigationBar horizontally? I've seen the barButtonItem setBackgroundVerticalPositionAdjustment:forBarMetrics: method (but that's for vertical positioning), and I know how to do it if I make it a custom button, but how do I take a UIBarButtonItem with the style UIBarButtonItemStyleBordered and horizontally reposition it (that is, move it left or right)?
Thanks in advance!
回答1:
You can create a fixed size button as a 'filler' and add that to beside your existing button:
UIBarButtonItem *fixedSpace = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFixedSpace target:nil action:nil];
(Then set the width to your desired value)
来源:https://stackoverflow.com/questions/17708353/horizontally-repositioning-a-uibarbuttonitem