Horizontally repositioning a UIBarButtonItem

天涯浪子 提交于 2019-12-24 02:42:22

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!