水平重新定位 UIBarButtonItem [英] Horizontally repositioning a UIBarButtonItem

查看:43
本文介绍了水平重新定位 UIBarButtonItem的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以水平重新定位 UINavigationBar 中的 UIBarButtonItem?我已经看到了 barButtonItem setBackgroundVerticalPositionAdjustment:forBarMetrics: 方法(但那是用于垂直定位)​​,如果我将其设为自定义按钮,我知道该怎么做,但是我如何获取 UIBarButtonItem 样式为 UIBarButtonItemStyleBordered 并水平重新定位(即向左或向右移动)?

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)?

提前致谢!

推荐答案

您可以创建一个固定大小的按钮作为填充"并将其添加到现有按钮旁边:

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)

这篇关于水平重新定位 UIBarButtonItem的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆