如何全局自定义后退按钮?

发布于 2024-09-04 06:07:18 字数 94 浏览 3 评论 0原文

有没有一种简单的方法(委托?覆盖?)全局自定义整个应用程序中 navigationBar 中使用的所有后退按钮?

最佳
–f

is there a simple way (Delegation? Overwriting?) do globally customize all the back buttons that are being used in the navigationBar throughout my whole app?

Best
–f

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

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

发布评论

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

评论(1

骷髅 2024-09-11 06:07:18

您能更具体地说明一下您的目标吗?对于大多数在全局范围内更改对象行为的尝试,您可以“调配”一个或多个方法,即切换为您的家庭烹饪提供的实现。如果不知道您想要实现什么目标,就不可能知道这是否对您有用。

我想做的就是使用自定义
UIButton(带有特定图形)用于
backButton 的 UIBarButtonItem。

在这种情况下,请考虑创建一个导航控制器工厂方法(可能作为您创建的类上的类方法,但您也可以在 UINavigationController 上的类别中执行此操作,该方法返回配置为的导航控制器实例每当您需要 UINavigationController 时,请调用该工厂方法而不是默认的初始化程序。

Could you be more specific about your goal? For most attempts to change an object's behviour globally, you can 'swizzle' one or more methods, that is, switch the supplied implementation for your home cooking. It's not possible to know if that can work for you without knowing what you want to achieve.

All I want to do is use a custom
UIButton (with a specific graphic) for
the UIBarButtonItem of the backButton.

In that case, consider creating a navigation controller factory method (probably as a class method on a class of your creation, but you could also do it in a category on UINavigationController that returns a navigation controller instance configured to your liking. Whenever you need a UINavigationController, call that factory method instead of the default initialiser.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文