不使用整个屏幕的导航控制器

Navigation Controller that doesn#39;t use the whole screen(不使用整个屏幕的导航控制器)
本文介绍了不使用整个屏幕的导航控制器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个导航控制器,我不想用完整个屏幕.特别是,我想在屏幕顶部的栏中放置一个徽标图像.不幸的是,导航控制器似乎不是这样设计的.在界面生成器中,我不能让它占据屏幕的一部分.您将如何实现顶部的徽标图像和占据屏幕其余部分的导航控制器的效果?

解决方案

我自己没有这样做,但应该很简单.您需要一个包装视图控制器作为其父级(我们称之为 MyWrapperViewController),其视图层次结构最终可能如下所示:

<上一页>UIView -+(连接到 MyWrapperViewController 中的视图出口)|+-- UIView(你的标志放在这里)|+-- UIView(子"导航控制器的视图)

徽标视图可以是 UIViewUIImageView 或任何适合内容的类.

当您在某处为您的 MyWrapperViewController 类创建 UINavigationController 时,您可以调整其 view bounds 的大小小于全屏(可能是屏幕大小减去您的徽标大小,并带有适当的 origin 偏移量,因此它位于徽标下方),然后将其添加为子视图.

I have a navigation controller which I don't want to use up the whole screen. In particular, I want to put a logo image in a bar at the top of the screen. Unfortunately, the navigation controller doesn't seem to be designed this way. In interface builder, I can't make it take up part of a screen. How would you achieve the effect of a logo image up the top and a navigation controller taking up the rest of the screen?

解决方案

I haven't done this myself, but it should be pretty straight-forward. You'll need a wrapper view controller to be its parent (let's call it MyWrapperViewController), and its view hierarchy might ultimately look something like this:

UIView -+ (hooked up to the view outlet in MyWrapperViewController)
        |
        +-- UIView (Your logo goes here)
        |
        +-- UIView (The "child" navigation controller's view)

The logo view can be a UIView, or a UIImageView, or whatever class is appropriate for the content.

When you create a UINavigationController somewhere for your MyWrapperViewController class, you can resize its view bounds to something smaller than full-screen (perhaps the size of the screen minus the size of your logo, with an appropriate origin offset so it's below the logo), and then add it as a subview.

这篇关于不使用整个屏幕的导航控制器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

tabbar middle tab out of tabbar corner(选项卡栏中间的选项卡角外)
Pushing UIViewController above UITabBar(将UIView控制器推送到UITabBar上方)
java.lang.IllegalStateException: SimpleTypeImpl should not be created for error type(异常:不应为错误类型创建SimpleTypeImpl)
Android IllegalArgumentException: The tag for fragment_XXX is invalid. Received: layout-sw600dp/fragment_XXX_0(Android IlLegalArgumentException:Fragment_XXX的标签无效。收到:Layout-sw600dp/Fragment_XXX_0)
iOS convert audio sample rate from 16 kHz to 8 kHz(IOS将音频采样率从16 kHz转换为8 kHz)
Enforcing an audio sampling rate in iOS(在iOS中强制音频采样率)