iPhone UINavigationController:仅对视图的一部分进行动画处理

发布于 2024-10-16 04:33:19 字数 211 浏览 5 评论 0原文

我有一个 UINavigationController,其中包含(从上到下)一个 UINavigationBar、一个 UIImageView 和一个 UITableView。我将推入堆栈的每个视图都在同一位置包含相同的 UIImageView (这是一个徽标)。

我希望徽标保留在 UINavigationBar 的正下方,当我推送/弹出视图时没有动画。 是否可以 ?

谢谢

I have a UINavigationController that contains (from top to bottom) a UINavigationBar, a UIImageView and a UITableView. Every view I will push in the stack contains the same UIImageView at the same place (this is a logo).

I would like the logo to stay just below the UINavigationBar, with no animation when I push/pop views.
Is it possible ?

Thanks

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

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

发布评论

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

评论(1

脸赞 2024-10-23 04:33:19

我认为实现此目的的唯一方法是将徽标图像视图直接添加到应用程序委托中的主窗口。将其放置在导航栏正下方。然后,您必须将视图控制器视图的背景颜色设置为清除,并确保 opaque 属性设置为 NO。调整视图大小并设置自动调整大小蒙版,以便将其锚定到屏幕底部(或选项卡栏或底部工具栏的顶部)。

基本上,您需要以这样的方式设置视图控制器的视图,使视图顶部的一部分完全透明。如果是这种情况,那么您直接添加到主窗口的徽标图像视图将始终可见。当使用导航控制器在视图控制器之间推送或弹出时,只需确保每个视图控制器的视图在徽标图像视图出现的右上角类似地设置为透明。即使导航控制器对过渡进行动画处理,视图顶部的透明度也应该只显示动画视图的不透明部分,以及导航栏及其子视图。

希望这是有道理的。

更新:根据 Noah Witherspoon 的评论,更好的方法可能是将图像徽标视图添加为导航控制器视图的子视图。您仍然需要调整视图控制器视图的大小,以便它们的内容不会被徽标图像视图遮挡,但这种方法总体上要干净得多。

The only way I can think to achieve this would be to add the logo image view directly to the main window in your app delegate. Position it so that it will appear directly below the navigation bar. Then you'll have to set the background color of your view controller's view to clear and ensure that the opaque property is set to NO. Size your view and set the autoresizing mask so that it will be anchored to the bottom of the screen (or to the top of a tab bar or bottom toolbar).

Basically, you need to set up your view controller's view in such a way that there is a portion of the top of the view that is completely transparent. If this is the case, then the logo image view you added directly to the main window will always be visible. When pushing or popping between view controllers using your navigation controller, just ensure that every view controller's view is similarly setup to be transparent at the top right where your logo image view appears. Even if the navigation controller animates the transition, the transparency at the top of your views should only show the opaque portions of your views being animated, along with the navigation bar and its subviews.

Hope that makes sense.

UPDATE: Per Noah Witherspoon's comment, a better approach would probably be just to add your image logo view as a subview of the navigation controller's view. You'll still have to size your view controllers' views so that their contents aren't obscured by your logo image view, but this approach overall is a lot cleaner.

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