如何始终在顶部显示 uiview? [英] How to show a uiview alway on top?

查看:32
本文介绍了如何始终在顶部显示 uiview?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在应用程序运行时始终在顶部显示 logo UIView,我知道有一种方法可以做到这一点,将相同的 UIView 添加到每个 UIViewController,但我认为这不是最好的方法.当我有很多页面,并且修改logo UIView时,必须每页都修改它.

I want to show a logo UIView always on top when the app running, I know there is a way to do that,add same UIView to every UIViewController, but I think this is not the best way to do that. when i have lot of pages,and modify the logo UIView,must modify it every page.

有人有更好的方法来做到这一点吗?谢谢.

Did someone have better way to do this? thanks.

看起来像这样:

推荐答案

由于每个应用程序只有一个窗口,并且视图没有级别,因此您必须确保视图位于层次结构的顶部,没有有什么关系.一种相对简单的方法是将其直接添加到界面其余部分(导航控制器)上方的窗口中:

Since you only every have one window per app, and view's don't have levels, you have to make sure that view stays on top of the hierarchy, no matter what. One relatively easy way is to add it directly to the window above the rest of the interface (the navigation controller):

applicationDidLaunch:

// After the main navigation controller or tab controller has been added
// either programmatically or in the xib:
UIImage *logo = [UIImage imageNamed:@"logo.png"];
UIImageView *logoView = [[UIImageView alloc] initWithImage:logo];
[self.window addSubview:logoView];

这篇关于如何始终在顶部显示 uiview?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆