这是 iOS 显示控制器作为右侧菜单的通用方法,灵感来源于《iOS进阶开发》一书的作者唐巧。您可以从该书第 12 章中找到一些关于 UIWindow 的有用知识。
利用 UIWindow 显示视图控制器作为右侧菜单。您可以为菜单视图指定与全屏相关的宽度百分比。您还可以设置弹出颜色(通常是半透明颜色)和显示侧菜单的动画持续时间。
AERightMenuWindow 简化了在应用程序中编写右侧菜单布局。让我们快速看一下示例:
这是一个从故事板加载的视图控制器,它使用 AERightMenuWindow 在指定的窗口中将其自身显示为右侧菜单。
// Step 1: Create your controllers.
UIStoryboard *mainStoryboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
MenuViewController *frontController = [mainStoryboard instantiateViewControllerWithIdentifier:@"MenuViewController"];
// Step2: Customize by define your own options
AERightMenuWindowOptions* options = [[AERightMenuWindowOptions alloc] init];
[options setDropBackColor:kAERightMenuWindowDropBackColor];
[options setAnimationInterval:kAERightMenuWindowAnimationInterval];
[options setMenuViewWidthPercentageOfFullScreen:0.80f];
[[AERightMenuWindow instance] setOptions:options];
// Step3: Show side menu
[[AERightMenuWindow instance] showMenu:frontController];
最初由 William(《@canicelebrate》)设计并构建。按照 MIT 许可证分发。