gpt4 book ai didi

iphone - 编写自己的 UINavigationController?类似的功能,而不是子类化

转载 作者:行者123 更新时间:2023-11-28 22:57:13 25 4
gpt4 key购买 nike

我需要一个具有与 UINavigationController 相同功能的自定义 View Controller 。为什么我不使用标准的是因为我真的需要一个自定义的 NavigationBar(超过 2 个按钮、标题和副标题、不同的高度等等...)

我正在尝试实现一个自定义 ViewController,其 View 充当标题,但我无法真正获得与原始 UINavigationViewController 相同的功能...

你将如何实现它?我花了 2 天时间(首先修改导航栏的外观,然后创建自定义导航栏,今天创建自定义 ViewController)

最佳答案

另请查看 iOS 5 中的 View Controller 包含(您可以在 iOS 5 中添加 subview Controller 并自行处理演示文稿)。

您可以在任何其他 View 上方使用透明导航栏(灵活大小 ^^),并使用核心动画作为过渡动画(与 UIKit 中的 push-pop-animation 相比,动画选项更多)。

确保子类化 UIViewController 并向其添加一个特殊的“custonNavigationController”属性(弱),您可以从自定义导航 Controller 进行设置;使用此类作为您的基本 View Controller 类(或者,创建一个您在 UIViewController、UITableViewController 的子类中实现的协议(protocol),...作为这些类型的基类)。您“可以”覆盖“旧”navigationController 属性的 getter 方法,以便您可以使用其他(Apple、第 3 方框架) View Controller 。

如果你想完美地为你的动画计时(而不是硬编码值 - 这应该足够了),你还可以实现 UINavigationBar 的委托(delegate)方法:)

到目前为止,这在我们的项目中效果很好。

关于iphone - 编写自己的 UINavigationController?类似的功能,而不是子类化,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10549385/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com