UINavigationBar 上缩进后退按钮?

发布于 2024-09-30 06:58:46 字数 71 浏览 0 评论 0原文

有没有办法缩进 UINavigationBar 上的默认后退按钮?基本上我只想将其向右移动大约 10 点。

谢谢

Is there any way to indent the default back button on a UINavigationBar? Basically I just want to move it about 10pts right.

Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

太阳男子 2024-10-07 06:58:46

隐藏默认的后退按钮对我有用,使用 UIButton,您可以随意设置样式:

...
UIBarButtonItem *backButtonItem = [[UIBarButtonItem alloc] initWithCustomView:button];
UIBarButtonItem *fixedspace = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFixedSpace target:nil action:nil];
fixedspace.width = 10.0f;

self.navigationItem.leftBarButtonItems = [NSArray arrayWithObjects:fixedspace, backButtonItem, nil];
...

Hiding the default back button worked for me, using a UIButton which you can style anyway you want:

...
UIBarButtonItem *backButtonItem = [[UIBarButtonItem alloc] initWithCustomView:button];
UIBarButtonItem *fixedspace = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFixedSpace target:nil action:nil];
fixedspace.width = 10.0f;

self.navigationItem.leftBarButtonItems = [NSArray arrayWithObjects:fixedspace, backButtonItem, nil];
...
音盲 2024-10-07 06:58:46

最好隐藏默认的后退按钮并在导航栏上添加自定义后退按钮。

一切顺利。

Better hide the default back button and add a custom back button on the navigation bar.

All the Best.

回眸一笑 2024-10-07 06:58:46

我认为没有简单的方法。但是您可以获得导航栏对象:

UINavigationBar *navBar = [navController navigationBar];

...并且可能迭代它的子视图。我想您可以根据它的框架属性确定哪个子视图是后退按钮。

I don't think there is an easy way. But you could get the navigation bar object:

UINavigationBar *navBar = [navController navigationBar];

...and maybe iterate through it's subviews. I presume you could determine which subview is the back button based on it's frame property.

多孤肩上扛 2024-10-07 06:58:46

如果有人遇到这个线程并且正在使用 iOS5,这似乎对我有用:

[[UIBarButtonItem appearance] setBackButtonTitlePositionAdjustment:UIOffsetMake(-1.0f, 0.0f) forBarMetrics:UIBarMetricsDefault];

If anyone comes across this thread and is using iOS5, this seemed to work for me:

[[UIBarButtonItem appearance] setBackButtonTitlePositionAdjustment:UIOffsetMake(-1.0f, 0.0f) forBarMetrics:UIBarMetricsDefault];
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文