我需要实现类似路径菜单之类的东西,无论用户留在哪个屏幕,它都在应用程序中全局可用。
请注意 我不是在问如何实现动画/样式设置,我只是对布局菜单交叉 View Controller 的正确方法感到好奇。
我目前采取的方法是:
应用的rootViewController
Controller 的 View ,使其出现在其他 subview 之上
对应的功能 View Controller 的 View 在前面,但是
仍在全局菜单 View 下
这种方法的缺点是:
简而言之,我设法达到了 UI/UX 的期望,但从技术上讲,我觉得我做错了。有没有人有类似的项目经验,请分享您的想法。
最佳答案
有两种解决方案,
然后您可以将全局菜单添加到导航 Controller View 中,例如,
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// Override point for customization after application launch.
self.window.backgroundColor = [UIColor whiteColor];
self.viewController = [[HomeViewController alloc] initWithNibName:nil bundle:nil];
self.navigationController = [[UINavigationController alloc] initWithRootViewController:self.viewController];
self.navigationController.delegate = self.viewController;
self.window.rootViewController = self.navigationController;
// Your Global Menu
UIButton *myButton ...
[self.navigationController.view addSubview:myButton];
[self.window makeKeyAndVisible];
return YES;
}
如,
#import "GlobalMenuView.h"
@interface BaseViewController : UIViewController
{
UIButton *btnMenu;
GlobalMenuView *globalMenu;
}
@end
然后想要全局菜单的 View Controller 就可以了,
#import "BaseViewController.h"
@interface YourOtherViewController: BaseViewController
{
}
@end
关于iphone - 如何使全局菜单悬停在所有屏幕上方,就像 Path 一样,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17203448/