在iOS上,如何向右水平移动navigationItem.leftBarButtonItem?
自定义的 UINavigationBar 要求我提供自定义的“后退”按钮,我使用 navigationItem.leftBarButtonItem = myCustomizedButton,但其位置是固定的。
有谁能分享一下如何将此按钮向右移动 40 像素吗?
A cusomized UINavigationBar requires me to present a customized "back" button, I use navigationItem.leftBarButtonItem = myCustomizedButton
, but its position is fixed.
Would anyone be so kind to share how can I shift this button 40pixels to right?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以创建比图像大 40 像素的包含视图。
以 40 像素偏移添加图像。
添加包含视图作为 leftBarButtonItem。
代码如下:
You can create a containing view that is 40 pixels bigger than your image.
Add your image at 40 pixels offset.
Add the containing view as the leftBarButtonItem.
Code follows:
您可以向导航栏上显示的图片添加空白区域。我遇到了同样的问题,这是我找到的唯一解决方案。有点棘手,但它有效......
You can add a blank space to your picture that you display on the navBar. I've had the same problem, and it's the only one solution i've found for resolve it. A little bit tricky but it works...