第七天 抽屉菜单(性能优化版)

开源库 RESideMenu


https://github.com/romaonthego/RESideMenu

使用


Code

In your AppDelegate’s - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions create the view controller and assign content and menu view controllers.

// Create content and menu controllers
//
DEMONavigationController *navigationController = [[DEMONavigationController alloc] initWithRootViewController:[[DEMOHomeViewController alloc] init]];
DEMOLeftMenuViewController *leftMenuViewController = [[DEMOLeftMenuViewController alloc] init];
DEMORightMenuViewController *rightMenuViewController = [[DEMORightMenuViewController alloc] init];

// Create side menu controller
//
RESideMenu *sideMenuViewController = [[RESideMenu alloc] initWithContentViewController:navigationController
leftMenuViewController:leftMenuViewController
rightMenuViewController:rightMenuViewController];
sideMenuViewController.backgroundImage = [UIImage imageNamed:@"Stars"];

// Make it a root controller
//
self.window.rootViewController = sideMenuViewController;

Present the menu view controller:

[self.sideMenuViewController presentLeftMenuViewController];

or

[self.sideMenuViewController presentRightMenuViewController];

Switch content view controllers:

#import <RESideMenu/RESideMenu.h>

....

[self.sideMenuViewController setContentViewController:viewController animated:YES];
[self.sideMenuViewController hideMenuViewController];

Storyboards Example

Create a subclass of RESideMenu. In this example we call it DEMORootViewController. In the Storyboard designate the root view’s owner as DEMORootViewController. Make sure to #import “RESideMenu.h” in DEMORootViewController.h. Add more view controllers to your Storyboard, and give them identifiers “leftMenuViewController”, “rightMenuViewController” and “contentViewController”. Note that in the new XCode the identifier is called “Storyboard ID” and can be found in the Identity inspector. Add a method awakeFromNib to DEMORootViewController.m with the following code:

- (void)awakeFromNib
{
     self.contentViewController = [self.storyboard instantiateViewControllerWithIdentifier:@"contentViewController"];
     self.leftMenuViewController = [self.storyboard instantiateViewControllerWithIdentifier:@"leftMenuViewController"];
     self.rightMenuViewController = [self.storyboard instantiateViewControllerWithIdentifier:@"rightMenuViewController"];

}
08 July 2015

开源库 REFrostedViewController


https://github.com/romaonthego/REFrostedViewController

Storyboards Example

  1. Create a subclass of REFrostedViewController. In this example we call it DEMORootViewController.
  2. In the Storyboard designate the root view’s owner as DEMORootViewController.
  3. Make sure to #import “REFrostedViewController.h” in DEMORootViewController.h.
  4. Add more view controllers to your Storyboard, and give them identifiers “menuController” and “contentController”. Note that in the new XCode the identifier is called “Storyboard ID” and can be found in the Identity inspector.
  5. Add a method awakeFromNib to DEMORootViewController.m with the following code:
- (void)awakeFromNib
{
	self.contentViewController = [self.storyboard instantiateViewControllerWithIdentifier:@"contentController"];
	self.menuViewController = [self.storyboard instantiateViewControllerWithIdentifier:@"menuController"];
}


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值