- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view.
self.view.backgroundColor = [UIColor clearColor];
//从故事板(storybord)中获取控制器对象
UIStoryboard *storybord = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
[[NSNotificationCenter defaultCenter]addObserver:selfselector:@selector(_setAnimation) name:kStyleNotification object:nil];
//设置左边的控制器
self.leftDrawerViewController = [storybord instantiateViewControllerWithIdentifier:@"LeftVC"];
//设置中间的控制器
self.centerViewController = [storybord instantiateViewControllerWithIdentifier:@"CenterVC"];
//设置右边的控制器
self.rightDrawerViewController = [storybord instantiateViewControllerWithIdentifier:@"RightVC"];
//设置阴影
[self setShowsShadow:YES];
//设置两边的宽度
[self setMaximumLeftDrawerWidth:160.0];
[self setMaximumRightDrawerWidth:60.0];
//设置手势的作用区域
[self setOpenDrawerGestureModeMask:MMOpenDrawerGestureModeAll];
[self setCloseDrawerGestureModeMask:MMCloseDrawerGestureModeAll];
//配置动画的回调函数
[self setDrawerVisualStateBlock:^(MMDrawerController *drawerController, MMDrawerSide drawerSide, CGFloat percentVisible) {
MMDrawerControllerDrawerVisualStateBlock block;
block = [[MMExampleDrawerVisualStateManagersharedManager]drawerVisualStateBlockForDrawerSide:drawerSide];
if (block) {
block(drawerController,drawerSide,percentVisible);
}
}];
//设置动画
[self _setAnimation];
}
//设置动画
- (void)_setAnimation
{
//从数据中拿到选中的样式
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
NSInteger style = [[defaults objectForKey:kAnimationStyle]integerValue];
//根据样式的枚举值设置动画
[[MMExampleDrawerVisualStateManager sharedManager] setLeftDrawerAnimationType:style];
[[MMExampleDrawerVisualStateManager sharedManager] setRightDrawerAnimationType:style];
}
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view.
self.view.backgroundColor = [UIColor clearColor];
//从故事板(storybord)中获取控制器对象
UIStoryboard *storybord = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
[[NSNotificationCenter defaultCenter]addObserver:selfselector:@selector(_setAnimation) name:kStyleNotification object:nil];
//设置左边的控制器
self.leftDrawerViewController = [storybord instantiateViewControllerWithIdentifier:@"LeftVC"];
//设置中间的控制器
self.centerViewController = [storybord instantiateViewControllerWithIdentifier:@"CenterVC"];
//设置右边的控制器
self.rightDrawerViewController = [storybord instantiateViewControllerWithIdentifier:@"RightVC"];
//设置阴影
[self setShowsShadow:YES];
//设置两边的宽度
[self setMaximumLeftDrawerWidth:160.0];
[self setMaximumRightDrawerWidth:60.0];
//设置手势的作用区域
[self setOpenDrawerGestureModeMask:MMOpenDrawerGestureModeAll];
[self setCloseDrawerGestureModeMask:MMCloseDrawerGestureModeAll];
//配置动画的回调函数
[self setDrawerVisualStateBlock:^(MMDrawerController *drawerController, MMDrawerSide drawerSide, CGFloat percentVisible) {
MMDrawerControllerDrawerVisualStateBlock block;
block = [[MMExampleDrawerVisualStateManagersharedManager]drawerVisualStateBlockForDrawerSide:drawerSide];
if (block) {
block(drawerController,drawerSide,percentVisible);
}
}];
//设置动画
[self _setAnimation];
}
//设置动画
- (void)_setAnimation
{
//从数据中拿到选中的样式
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
NSInteger style = [[defaults objectForKey:kAnimationStyle]integerValue];
//根据样式的枚举值设置动画
[[MMExampleDrawerVisualStateManager sharedManager] setLeftDrawerAnimationType:style];
[[MMExampleDrawerVisualStateManager sharedManager] setRightDrawerAnimationType:style];
}