将uiviewcontrollers移到后面

时间:2014-08-04 05:16:57

标签: ios objective-c uiviewcontroller

我有一个我正在构建的应用程序,需要将uiview或uiviewcontroller保持在最顶层。描述它的最好方法是通过一个例子。想象一个网站,浮动菜单始终位于屏幕中央的顶部。在导航栏下方导航新页面时加载。

我正在寻找的是一种将自定义UIView保持在最顶层的方式(即最前面的uiview或最前面的uiview控制器),但在其下面滑动新的viewcontroller。该设计不适用于容器视图,因为当应用程序首次加载菜单栏(或我的自定义浮动菜单视图)时,就是在ContainerViewcontroller上。这个containerView包含几个容器视图。

任何建议或帮助都将不胜感激。我很确定这是不可能的,但我想要做的是使用导航栏/堆栈并按下视图控制器,但总是在菜单下面。或者使用addChildViewController,但是在最顶层的viewcontroller(即我的菜单)下面。

更新:我可以这样做吗?

self.newviewcontroller.view.frame = CGRectMake(0, -200, self.view.bounds.size.width, 96);
self.newviewcontroller.view.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
[self.view addSubview:self.newviewcontroller.view];
[self addChildViewController:self.newviewcontroller];
[self.newviewcontroller didMoveToParentViewController:self];

[self.view bringSubviewToFront:mainFloatingMenu];

// THen animate the new view onto the screen
[UIView animateWithDuration:0.4
                      delay:0.3
                    options:(UIViewAnimationCurveEaseOut)
                 animations:^{
                     self.newviewcontroller.view.frame = CGRectMake(0, 0,   self.view.bounds.size.width, self.view.bounds.size.height);
                 } completion:^(BOOL finished) {

                     // do notta
                 }];

1 个答案:

答案 0 :(得分:0)

[self.view insertSubview:mainFloatingMenu aboveSubview:mainView]; 

[self.view insertSubview:floatingMenu atIndex:20000];