From 99308f9d159d3c9fb26648d39055b2a27b633c1a Mon Sep 17 00:00:00 2001 From: Pedro Scocco Date: Wed, 2 Apr 2014 19:20:10 -0300 Subject: [PATCH 01/13] Fixed example's option when re-enable any of the sides --- .../MMExampleCenterTableViewController.m | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/KitchenSink/ExampleFiles/MMExampleCenterTableViewController.m b/KitchenSink/ExampleFiles/MMExampleCenterTableViewController.m index 98ade210..8b8598cc 100644 --- a/KitchenSink/ExampleFiles/MMExampleCenterTableViewController.m +++ b/KitchenSink/ExampleFiles/MMExampleCenterTableViewController.m @@ -323,15 +323,24 @@ - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath else { if(drawerSide == MMDrawerSideLeft){ UIViewController * vc = [[MMExampleLeftSideDrawerViewController alloc] init]; - UINavigationController * navC = [[MMNavigationController alloc] initWithRootViewController:vc]; - [self.mm_drawerController setLeftDrawerViewController:navC]; + if(OSVersionIsAtLeastiOS7()){ + UINavigationController * navC = [[MMNavigationController alloc] initWithRootViewController:vc]; + [self.mm_drawerController setLeftDrawerViewController:navC]; + } + else { + [self.mm_drawerController setLeftDrawerViewController:vc]; + } [self setupLeftMenuButton]; - } else if(drawerSide == MMDrawerSideRight){ UIViewController * vc = [[MMExampleRightSideDrawerViewController alloc] init]; - UINavigationController * navC = [[MMNavigationController alloc] initWithRootViewController:vc]; - [self.mm_drawerController setRightDrawerViewController:navC]; + if(drawerSide == MMDrawerSideLeft){ + UINavigationController * navC = [[MMNavigationController alloc] initWithRootViewController:vc]; + [self.mm_drawerController setRightDrawerViewController:navC]; + } + else { + [self.mm_drawerController setRightDrawerViewController:vc]; + } [self setupRightMenuButton]; } [tableView reloadRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationNone]; From aa538c419442a548abdf4c69a978db54983f9c66 Mon Sep 17 00:00:00 2001 From: Pedro Scocco Date: Wed, 2 Apr 2014 20:33:20 -0300 Subject: [PATCH 02/13] New status bar option with variable opacity. This solution mimics the contacts drawer used in the facebook App, where the status bar background becomes visible as the drawer opens. --- MMDrawerController/MMDrawerController.h | 8 +++++++- MMDrawerController/MMDrawerController.m | 24 +++++++++++++++++------- 2 files changed, 24 insertions(+), 8 deletions(-) diff --git a/MMDrawerController/MMDrawerController.h b/MMDrawerController/MMDrawerController.h index bf895cbb..fa0dbc7b 100644 --- a/MMDrawerController/MMDrawerController.h +++ b/MMDrawerController/MMDrawerController.h @@ -92,6 +92,12 @@ typedef NS_ENUM(NSInteger, MMDrawerOpenCenterInteractionMode) { MMDrawerOpenCenterInteractionModeNavigationBarOnly, }; +typedef NS_ENUM(NSInteger, MMStatusBarBackgroundViewMode) { + MMStatusBarBackgroundViewModeNone = 0, + MMStatusBarBackgroundViewModeOpaque, + MMStatusBarBackgroundViewModeVariable, +}; + @class MMDrawerController; typedef void (^MMDrawerControllerDrawerVisualStateBlock)(MMDrawerController * drawerController, MMDrawerSide drawerSide, CGFloat percentVisible); @@ -205,7 +211,7 @@ typedef void (^MMDrawerControllerDrawerVisualStateBlock)(MMDrawerController * dr By default, this is set to NO. If running on < iOS 7.0, it will always return NO. */ -@property (nonatomic, assign) BOOL showsStatusBarBackgroundView; +@property (nonatomic, assign) MMStatusBarBackgroundViewMode statusBarBackgroundViewMode; /** The color of the status bar background view if `showsStatusBarBackgroundView` is set to YES. This value is ignored in < iOS 7.0. diff --git a/MMDrawerController/MMDrawerController.m b/MMDrawerController/MMDrawerController.m index a516bf46..84fc9bfd 100644 --- a/MMDrawerController/MMDrawerController.m +++ b/MMDrawerController/MMDrawerController.m @@ -300,6 +300,7 @@ -(void)closeDrawerAnimated:(BOOL)animated velocity:(CGFloat)velocity animationOp [self setNeedsStatusBarAppearanceUpdateIfSupported]; [self.centerContainerView setFrame:newFrame]; [self updateDrawerVisualStateForDrawerSide:visibleSide percentVisible:0.0]; + [self updateStatusBarBackgroundViewAlpha:0.0f]; } completion:^(BOOL finished) { [sideDrawerViewController endAppearanceTransition]; @@ -359,6 +360,7 @@ -(void)openDrawerSide:(MMDrawerSide)drawerSide animated:(BOOL)animated velocity: [self setNeedsStatusBarAppearanceUpdateIfSupported]; [self.centerContainerView setFrame:newFrame]; [self updateDrawerVisualStateForDrawerSide:drawerSide percentVisible:1.0]; + [self updateStatusBarBackgroundViewAlpha:1.0f]; } completion:^(BOOL finished) { //End the appearance transition if it already wasn't open. @@ -835,14 +837,14 @@ -(void)setMaximumRightDrawerWidth:(CGFloat)maximumRightDrawerWidth{ [self setMaximumRightDrawerWidth:maximumRightDrawerWidth animated:NO completion:nil]; } --(void)setShowsStatusBarBackgroundView:(BOOL)showsDummyStatusBar{ +-(void)setStatusBarBackgroundViewMode:(MMStatusBarBackgroundViewMode)dummyStatusBarMode{ NSArray *sysVersion = [[UIDevice currentDevice].systemVersion componentsSeparatedByString:@"."]; float majorVersion = [[sysVersion objectAtIndex:0] floatValue]; if (majorVersion >= 7){ - if(showsDummyStatusBar!=_showsStatusBarBackgroundView){ - _showsStatusBarBackgroundView = showsDummyStatusBar; + if(dummyStatusBarMode!=_statusBarBackgroundViewMode){ + _statusBarBackgroundViewMode = dummyStatusBarMode; CGRect frame = self.childControllerContainerView.frame; - if(_showsStatusBarBackgroundView){ + if(_statusBarBackgroundViewMode == MMStatusBarBackgroundViewModeOpaque){ frame.origin.y = 20; frame.size.height = CGRectGetHeight(self.view.bounds)-20; } @@ -851,11 +853,11 @@ -(void)setShowsStatusBarBackgroundView:(BOOL)showsDummyStatusBar{ frame.size.height = CGRectGetHeight(self.view.bounds); } [self.childControllerContainerView setFrame:frame]; - [self.dummyStatusBarView setHidden:!showsDummyStatusBar]; + [self.dummyStatusBarView setHidden:!dummyStatusBarMode]; } } else { - _showsStatusBarBackgroundView = NO; + _statusBarBackgroundViewMode = MMStatusBarBackgroundViewModeNone; } } @@ -922,7 +924,7 @@ -(UIView*)dummyStatusBarView{ _dummyStatusBarView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, CGRectGetWidth(self.view.bounds), 20)]; [_dummyStatusBarView setAutoresizingMask:UIViewAutoresizingFlexibleWidth]; [_dummyStatusBarView setBackgroundColor:self.statusBarViewBackgroundColor]; - [_dummyStatusBarView setHidden:!_showsStatusBarBackgroundView]; + [_dummyStatusBarView setHidden:!_statusBarBackgroundViewMode]; [self.view addSubview:_dummyStatusBarView]; } return _dummyStatusBarView; @@ -993,6 +995,7 @@ -(void)panGestureCallback:(UIPanGestureRecognizer *)panGesture{ [self setOpenSide:MMDrawerSideNone]; } + [self updateStatusBarBackgroundViewAlpha:percentVisible]; [self updateDrawerVisualStateForDrawerSide:visibleSide percentVisible:percentVisible]; [self.centerContainerView setCenter:CGPointMake(CGRectGetMidX(newFrame), CGRectGetMidY(newFrame))]; @@ -1032,6 +1035,13 @@ -(void)setNeedsStatusBarAppearanceUpdateIfSupported{ } } +-(void)updateStatusBarBackgroundViewAlpha:(CGFloat)alpha +{ + if (_statusBarBackgroundViewMode == MMStatusBarBackgroundViewModeVariable) { + [_dummyStatusBarView setAlpha:alpha]; + } +} + #pragma mark - Animation helpers -(void)finishAnimationForPanGestureWithXVelocity:(CGFloat)xVelocity completion:(void(^)(BOOL finished))completion{ CGFloat currentOriginX = CGRectGetMinX(self.centerContainerView.frame); From 295dda5bb849e17465672612592043ae47bb662b Mon Sep 17 00:00:00 2001 From: Pedro Scocco Date: Wed, 2 Apr 2014 20:49:51 -0300 Subject: [PATCH 03/13] New method for backwards compatibility. New property description. --- MMDrawerController/MMDrawerController.h | 11 +++++++++-- MMDrawerController/MMDrawerController.m | 5 +++++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/MMDrawerController/MMDrawerController.h b/MMDrawerController/MMDrawerController.h index fa0dbc7b..fbb94f63 100644 --- a/MMDrawerController/MMDrawerController.h +++ b/MMDrawerController/MMDrawerController.h @@ -207,9 +207,11 @@ typedef void (^MMDrawerControllerDrawerVisualStateBlock)(MMDrawerController * dr @property (nonatomic, assign) BOOL showsShadow; /** - The flag determining if a custom background view should appear beneath the status bar, forcing the child content to be drawn lower than the status bar. This property is only available for > iOS 7.0 to take into account for the new behavior of the status bar. + The value determining if a custom background view will appear beneath the status bar. This property is only available for > iOS 7.0 to take into account for the new behavior of the status bar. - By default, this is set to NO. If running on < iOS 7.0, it will always return NO. + If set to `MMStatusBarBackgroundViewModeOpaque` the child content will be drawn lower than the status bar. + + By default, this is set to `MMStatusBarBackgroundViewModeNone`. If running on < iOS 7.0, it will always return `MMStatusBarBackgroundViewModeNone`. */ @property (nonatomic, assign) MMStatusBarBackgroundViewMode statusBarBackgroundViewMode; @@ -416,4 +418,9 @@ typedef void (^MMDrawerControllerDrawerVisualStateBlock)(MMDrawerController * dr */ -(void)setGestureShouldRecognizeTouchBlock:(BOOL(^)(MMDrawerController * drawerController, UIGestureRecognizer * gesture, UITouch * touch))gestureShouldRecognizeTouchBlock; +/** + Method create for backwards compatibility. When called with param YES, `statusBarBackgroundViewMode` will be set to `MMStatusBarBackgroundViewModeOpaque`. + */ +-(void)setShowsStatusBarBackgroundView:(BOOL)showsBackgroundFlag; + @end diff --git a/MMDrawerController/MMDrawerController.m b/MMDrawerController/MMDrawerController.m index 84fc9bfd..fd866355 100644 --- a/MMDrawerController/MMDrawerController.m +++ b/MMDrawerController/MMDrawerController.m @@ -1021,6 +1021,11 @@ -(void)panGestureCallback:(UIPanGestureRecognizer *)panGesture{ } #pragma mark - iOS 7 Status Bar Helpers +-(void)setShowsStatusBarBackgroundView:(BOOL)showsBackgroundFlag +{ + _statusBarBackgroundViewMode=showsBackgroundFlag?MMStatusBarBackgroundViewModeOpaque:MMStatusBarBackgroundViewModeNone; +} + -(UIViewController*)childViewControllerForStatusBarStyle{ return [self childViewControllerForSide:self.openSide]; } From d58aa6ba0f24bcaa9c087699b4180cec43484630 Mon Sep 17 00:00:00 2001 From: Pedro Scocco Date: Thu, 3 Apr 2014 08:26:12 -0300 Subject: [PATCH 04/13] New example options to test the Status Bar Background View. --- .../MMExampleCenterTableViewController.m | 37 ++++++++++++++++++- MMDrawerController/MMDrawerController.h | 2 +- 2 files changed, 37 insertions(+), 2 deletions(-) diff --git a/KitchenSink/ExampleFiles/MMExampleCenterTableViewController.m b/KitchenSink/ExampleFiles/MMExampleCenterTableViewController.m index 8b8598cc..da77b2d2 100644 --- a/KitchenSink/ExampleFiles/MMExampleCenterTableViewController.m +++ b/KitchenSink/ExampleFiles/MMExampleCenterTableViewController.m @@ -32,6 +32,7 @@ #import typedef NS_ENUM(NSInteger, MMCenterViewControllerSection){ + MMCenterViewControllerSectionStatusBarBackgroundState, MMCenterViewControllerSectionLeftViewState, MMCenterViewControllerSectionLeftDrawerAnimation, MMCenterViewControllerSectionRightViewState, @@ -145,7 +146,7 @@ -(void)contentSizeDidChange:(NSString *)size{ - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { - return 4; + return 5; } - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section @@ -158,6 +159,8 @@ - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger case MMCenterViewControllerSectionLeftViewState: case MMCenterViewControllerSectionRightViewState: return 1; + case MMCenterViewControllerSectionStatusBarBackgroundState: + return 3; default: return 0; } @@ -186,6 +189,30 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N alpha:1.0]; switch (indexPath.section) { + case MMCenterViewControllerSectionStatusBarBackgroundState: + if(self.mm_drawerController.statusBarBackgroundViewMode == indexPath.row){ + [cell setAccessoryType:UITableViewCellAccessoryCheckmark]; + [cell.textLabel setTextColor:selectedColor]; + NSLog(@"%d", self.mm_drawerController.statusBarBackgroundViewMode); + } + else { + [cell setAccessoryType:UITableViewCellAccessoryNone]; + [cell.textLabel setTextColor:unselectedColor]; + } + switch (indexPath.row) { + case MMStatusBarBackgroundViewModeNone: + [cell.textLabel setText:@"None"]; + break; + case MMStatusBarBackgroundViewModeOpaque: + [cell.textLabel setText:@"Opaque"]; + break; + case MMStatusBarBackgroundViewModeVariable: + [cell.textLabel setText:@"Variable"]; + break; + default: + break; + } + break; case MMCenterViewControllerSectionLeftDrawerAnimation: case MMCenterViewControllerSectionRightDrawerAnimation:{ MMDrawerAnimationType animationTypeForSection; @@ -258,6 +285,8 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N -(NSString*)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section{ switch (section) { + case MMCenterViewControllerSectionStatusBarBackgroundState: + return @"Status Bar Background View Mode"; case MMCenterViewControllerSectionLeftDrawerAnimation: return @"Left Drawer Animation"; case MMCenterViewControllerSectionRightDrawerAnimation: @@ -276,6 +305,12 @@ -(NSString*)tableView:(UITableView *)tableView titleForHeaderInSection:(NSIntege - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { switch (indexPath.section) { + case MMCenterViewControllerSectionStatusBarBackgroundState: + [self.mm_drawerController setStatusBarBackgroundViewMode:indexPath.row]; + [tableView reloadSections:[NSIndexSet indexSetWithIndex:indexPath.section] withRowAnimation:UITableViewRowAnimationNone]; + [tableView selectRowAtIndexPath:indexPath animated:NO scrollPosition:UITableViewScrollPositionNone]; + [tableView deselectRowAtIndexPath:indexPath animated:YES]; + break; case MMCenterViewControllerSectionLeftDrawerAnimation: case MMCenterViewControllerSectionRightDrawerAnimation:{ if(indexPath.section == MMCenterViewControllerSectionLeftDrawerAnimation){ diff --git a/MMDrawerController/MMDrawerController.h b/MMDrawerController/MMDrawerController.h index fbb94f63..cf50731b 100644 --- a/MMDrawerController/MMDrawerController.h +++ b/MMDrawerController/MMDrawerController.h @@ -94,8 +94,8 @@ typedef NS_ENUM(NSInteger, MMDrawerOpenCenterInteractionMode) { typedef NS_ENUM(NSInteger, MMStatusBarBackgroundViewMode) { MMStatusBarBackgroundViewModeNone = 0, - MMStatusBarBackgroundViewModeOpaque, MMStatusBarBackgroundViewModeVariable, + MMStatusBarBackgroundViewModeOpaque, }; @class MMDrawerController; From a9887609e1d0f439c690f079bb410437ce2c372a Mon Sep 17 00:00:00 2001 From: Pedro Scocco Date: Thu, 3 Apr 2014 08:29:32 -0300 Subject: [PATCH 05/13] New method for backwards compatibility. Getter. --- MMDrawerController/MMDrawerController.h | 1 + MMDrawerController/MMDrawerController.m | 7 +++++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/MMDrawerController/MMDrawerController.h b/MMDrawerController/MMDrawerController.h index cf50731b..c5d98188 100644 --- a/MMDrawerController/MMDrawerController.h +++ b/MMDrawerController/MMDrawerController.h @@ -421,6 +421,7 @@ typedef void (^MMDrawerControllerDrawerVisualStateBlock)(MMDrawerController * dr /** Method create for backwards compatibility. When called with param YES, `statusBarBackgroundViewMode` will be set to `MMStatusBarBackgroundViewModeOpaque`. */ +-(BOOL)showsStatusBarBackgroundView; -(void)setShowsStatusBarBackgroundView:(BOOL)showsBackgroundFlag; @end diff --git a/MMDrawerController/MMDrawerController.m b/MMDrawerController/MMDrawerController.m index fd866355..5937b6d8 100644 --- a/MMDrawerController/MMDrawerController.m +++ b/MMDrawerController/MMDrawerController.m @@ -1021,8 +1021,11 @@ -(void)panGestureCallback:(UIPanGestureRecognizer *)panGesture{ } #pragma mark - iOS 7 Status Bar Helpers --(void)setShowsStatusBarBackgroundView:(BOOL)showsBackgroundFlag -{ +-(BOOL)showsStatusBarBackgroundView{ + return _statusBarBackgroundViewMode != MMStatusBarBackgroundViewModeNone; +} + +-(void)setShowsStatusBarBackgroundView:(BOOL)showsBackgroundFlag{ _statusBarBackgroundViewMode=showsBackgroundFlag?MMStatusBarBackgroundViewModeOpaque:MMStatusBarBackgroundViewModeNone; } From e81a3c202854f3481fb3385d4ccded45bf9fefc2 Mon Sep 17 00:00:00 2001 From: Pedro Scocco Date: Thu, 3 Apr 2014 09:10:36 -0300 Subject: [PATCH 06/13] Setting default aplha when changing statusBarBackgroundViewMode. --- MMDrawerController/MMDrawerController.m | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/MMDrawerController/MMDrawerController.m b/MMDrawerController/MMDrawerController.m index 5937b6d8..da41cbfd 100644 --- a/MMDrawerController/MMDrawerController.m +++ b/MMDrawerController/MMDrawerController.m @@ -300,7 +300,7 @@ -(void)closeDrawerAnimated:(BOOL)animated velocity:(CGFloat)velocity animationOp [self setNeedsStatusBarAppearanceUpdateIfSupported]; [self.centerContainerView setFrame:newFrame]; [self updateDrawerVisualStateForDrawerSide:visibleSide percentVisible:0.0]; - [self updateStatusBarBackgroundViewAlpha:0.0f]; + [self updateStatusBarBackgroundViewWithAlpha:0.0f]; } completion:^(BOOL finished) { [sideDrawerViewController endAppearanceTransition]; @@ -360,7 +360,7 @@ -(void)openDrawerSide:(MMDrawerSide)drawerSide animated:(BOOL)animated velocity: [self setNeedsStatusBarAppearanceUpdateIfSupported]; [self.centerContainerView setFrame:newFrame]; [self updateDrawerVisualStateForDrawerSide:drawerSide percentVisible:1.0]; - [self updateStatusBarBackgroundViewAlpha:1.0f]; + [self updateStatusBarBackgroundViewWithAlpha:1.0f]; } completion:^(BOOL finished) { //End the appearance transition if it already wasn't open. @@ -847,11 +847,14 @@ -(void)setStatusBarBackgroundViewMode:(MMStatusBarBackgroundViewMode)dummyStatus if(_statusBarBackgroundViewMode == MMStatusBarBackgroundViewModeOpaque){ frame.origin.y = 20; frame.size.height = CGRectGetHeight(self.view.bounds)-20; + [self.dummyStatusBarView setAlpha:1.0]; } else { frame.origin.y = 0; frame.size.height = CGRectGetHeight(self.view.bounds); + [self updateStatusBarBackgroundViewAlpa]; } + [self setNeedsStatusBarAppearanceUpdateIfSupported]; [self.childControllerContainerView setFrame:frame]; [self.dummyStatusBarView setHidden:!dummyStatusBarMode]; } @@ -995,7 +998,7 @@ -(void)panGestureCallback:(UIPanGestureRecognizer *)panGesture{ [self setOpenSide:MMDrawerSideNone]; } - [self updateStatusBarBackgroundViewAlpha:percentVisible]; + [self updateStatusBarBackgroundViewWithAlpha:percentVisible]; [self updateDrawerVisualStateForDrawerSide:visibleSide percentVisible:percentVisible]; [self.centerContainerView setCenter:CGPointMake(CGRectGetMidX(newFrame), CGRectGetMidY(newFrame))]; @@ -1043,10 +1046,16 @@ -(void)setNeedsStatusBarAppearanceUpdateIfSupported{ } } --(void)updateStatusBarBackgroundViewAlpha:(CGFloat)alpha +- (void)updateStatusBarBackgroundViewAlpa{ + CGFloat visibleDrawerPoints = CGRectGetMinX(self.centerContainerView.frame); + CGFloat percentVisble = MAX(0.0,visibleDrawerPoints/self.maximumLeftDrawerWidth); + [self updateStatusBarBackgroundViewWithAlpha:percentVisble]; +} + +-(void)updateStatusBarBackgroundViewWithAlpha:(CGFloat)alpha { if (_statusBarBackgroundViewMode == MMStatusBarBackgroundViewModeVariable) { - [_dummyStatusBarView setAlpha:alpha]; + [self.dummyStatusBarView setAlpha:alpha]; } } From 818910fdc80172790a81d108a37cd3f797b21298 Mon Sep 17 00:00:00 2001 From: Pedro Scocco Date: Thu, 3 Apr 2014 09:15:09 -0300 Subject: [PATCH 07/13] Fixed example's NavBar height when changing statusBarBackground Mode. --- .../ExampleFiles/MMExampleCenterTableViewController.m | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/KitchenSink/ExampleFiles/MMExampleCenterTableViewController.m b/KitchenSink/ExampleFiles/MMExampleCenterTableViewController.m index da77b2d2..926a5135 100644 --- a/KitchenSink/ExampleFiles/MMExampleCenterTableViewController.m +++ b/KitchenSink/ExampleFiles/MMExampleCenterTableViewController.m @@ -193,7 +193,6 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N if(self.mm_drawerController.statusBarBackgroundViewMode == indexPath.row){ [cell setAccessoryType:UITableViewCellAccessoryCheckmark]; [cell.textLabel setTextColor:selectedColor]; - NSLog(@"%d", self.mm_drawerController.statusBarBackgroundViewMode); } else { [cell setAccessoryType:UITableViewCellAccessoryNone]; @@ -304,9 +303,17 @@ -(NSString*)tableView:(UITableView *)tableView titleForHeaderInSection:(NSIntege - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { + MMExampleCenterTableViewController * center; + UINavigationController * nav; + switch (indexPath.section) { case MMCenterViewControllerSectionStatusBarBackgroundState: [self.mm_drawerController setStatusBarBackgroundViewMode:indexPath.row]; + + center = [[MMExampleCenterTableViewController alloc] init]; + nav = [[MMNavigationController alloc] initWithRootViewController:center]; + self.mm_drawerController.centerViewController = nav; + [tableView reloadSections:[NSIndexSet indexSetWithIndex:indexPath.section] withRowAnimation:UITableViewRowAnimationNone]; [tableView selectRowAtIndexPath:indexPath animated:NO scrollPosition:UITableViewScrollPositionNone]; [tableView deselectRowAtIndexPath:indexPath animated:YES]; From 00959682cba7767eddb863b1d3d0eea781a579d8 Mon Sep 17 00:00:00 2001 From: Pedro Scocco Date: Thu, 3 Apr 2014 10:09:31 -0300 Subject: [PATCH 08/13] Fixed example's navBar color in iOS 7 --- .../ExampleFiles/MMExampleCenterTableViewController.m | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/KitchenSink/ExampleFiles/MMExampleCenterTableViewController.m b/KitchenSink/ExampleFiles/MMExampleCenterTableViewController.m index 926a5135..c1a9c068 100644 --- a/KitchenSink/ExampleFiles/MMExampleCenterTableViewController.m +++ b/KitchenSink/ExampleFiles/MMExampleCenterTableViewController.m @@ -79,9 +79,9 @@ - (void)viewDidLoad if(OSVersionIsAtLeastiOS7()){ UIColor * barColor = [UIColor - colorWithRed:247.0/255.0 - green:249.0/255.0 - blue:250.0/255.0 + colorWithRed:217.0/255.0 + green:219.0/255.0 + blue:220.0/255.0 alpha:1.0]; [self.navigationController.navigationBar setBarTintColor:barColor]; } From 92ba52414ccc4e7bea02afb6258a909e44cccb15 Mon Sep 17 00:00:00 2001 From: Pedro Scocco Date: Thu, 3 Apr 2014 11:06:51 -0300 Subject: [PATCH 09/13] Fixed full close animation status bar alpha animation --- .../MMDrawerControllerKitchenSink.xccheckout | 16 ++++++++-------- MMDrawerController/MMDrawerController.m | 1 + 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/KitchenSink/MMDrawerControllerKitchenSink.xcodeproj/project.xcworkspace/xcshareddata/MMDrawerControllerKitchenSink.xccheckout b/KitchenSink/MMDrawerControllerKitchenSink.xcodeproj/project.xcworkspace/xcshareddata/MMDrawerControllerKitchenSink.xccheckout index 2bf4fcb5..5dd1e890 100644 --- a/KitchenSink/MMDrawerControllerKitchenSink.xcodeproj/project.xcworkspace/xcshareddata/MMDrawerControllerKitchenSink.xccheckout +++ b/KitchenSink/MMDrawerControllerKitchenSink.xcodeproj/project.xcworkspace/xcshareddata/MMDrawerControllerKitchenSink.xccheckout @@ -5,36 +5,36 @@ IDESourceControlProjectFavoriteDictionaryKey IDESourceControlProjectIdentifier - 88813EDE-C4BC-4EAD-BA3F-F5FC71109468 + 75CC6C82-8CFF-4B5C-9898-FD531DDFEFE1 IDESourceControlProjectName MMDrawerControllerKitchenSink IDESourceControlProjectOriginsDictionary - C486FB0C-7803-4607-BCA9-799E743ECFBA - https://github.com/mutualmobile/MMDrawerController.git + 10AE6131-1D2C-4A0A-B449-E2ACBCFF5ECD + ssh://github.com/pedroscocco/MMDrawerController.git IDESourceControlProjectPath KitchenSink/MMDrawerControllerKitchenSink.xcodeproj/project.xcworkspace IDESourceControlProjectRelativeInstallPathDictionary - C486FB0C-7803-4607-BCA9-799E743ECFBA + 10AE6131-1D2C-4A0A-B449-E2ACBCFF5ECD ../../.. IDESourceControlProjectURL - https://github.com/mutualmobile/MMDrawerController.git + ssh://github.com/pedroscocco/MMDrawerController.git IDESourceControlProjectVersion 110 IDESourceControlProjectWCCIdentifier - C486FB0C-7803-4607-BCA9-799E743ECFBA + 10AE6131-1D2C-4A0A-B449-E2ACBCFF5ECD IDESourceControlProjectWCConfigurations IDESourceControlRepositoryExtensionIdentifierKey public.vcs.git IDESourceControlWCCIdentifierKey - C486FB0C-7803-4607-BCA9-799E743ECFBA + 10AE6131-1D2C-4A0A-B449-E2ACBCFF5ECD IDESourceControlWCCName - MMDrawerController-GitHub + MMDrawerController diff --git a/MMDrawerController/MMDrawerController.m b/MMDrawerController/MMDrawerController.m index da41cbfd..592ed8aa 100644 --- a/MMDrawerController/MMDrawerController.m +++ b/MMDrawerController/MMDrawerController.m @@ -512,6 +512,7 @@ -(void)setCenterViewController:(UIViewController *)newCenterViewController withF animations:^{ [self.centerContainerView setFrame:self.childControllerContainerView.bounds]; [self updateDrawerVisualStateForDrawerSide:self.openSide percentVisible:0.0]; + [self updateStatusBarBackgroundViewWithAlpha:0.0f]; } completion:^(BOOL finished) { if (forwardAppearanceMethodsToCenterViewController) { From 8b388bc9d39456495b58d237ea3f205679341e5f Mon Sep 17 00:00:00 2001 From: Pedro Scocco Date: Thu, 3 Apr 2014 11:38:01 -0300 Subject: [PATCH 10/13] Revert .xcheckout changes --- .../MMDrawerControllerKitchenSink.xccheckout | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/KitchenSink/MMDrawerControllerKitchenSink.xcodeproj/project.xcworkspace/xcshareddata/MMDrawerControllerKitchenSink.xccheckout b/KitchenSink/MMDrawerControllerKitchenSink.xcodeproj/project.xcworkspace/xcshareddata/MMDrawerControllerKitchenSink.xccheckout index 5dd1e890..2bf4fcb5 100644 --- a/KitchenSink/MMDrawerControllerKitchenSink.xcodeproj/project.xcworkspace/xcshareddata/MMDrawerControllerKitchenSink.xccheckout +++ b/KitchenSink/MMDrawerControllerKitchenSink.xcodeproj/project.xcworkspace/xcshareddata/MMDrawerControllerKitchenSink.xccheckout @@ -5,36 +5,36 @@ IDESourceControlProjectFavoriteDictionaryKey IDESourceControlProjectIdentifier - 75CC6C82-8CFF-4B5C-9898-FD531DDFEFE1 + 88813EDE-C4BC-4EAD-BA3F-F5FC71109468 IDESourceControlProjectName MMDrawerControllerKitchenSink IDESourceControlProjectOriginsDictionary - 10AE6131-1D2C-4A0A-B449-E2ACBCFF5ECD - ssh://github.com/pedroscocco/MMDrawerController.git + C486FB0C-7803-4607-BCA9-799E743ECFBA + https://github.com/mutualmobile/MMDrawerController.git IDESourceControlProjectPath KitchenSink/MMDrawerControllerKitchenSink.xcodeproj/project.xcworkspace IDESourceControlProjectRelativeInstallPathDictionary - 10AE6131-1D2C-4A0A-B449-E2ACBCFF5ECD + C486FB0C-7803-4607-BCA9-799E743ECFBA ../../.. IDESourceControlProjectURL - ssh://github.com/pedroscocco/MMDrawerController.git + https://github.com/mutualmobile/MMDrawerController.git IDESourceControlProjectVersion 110 IDESourceControlProjectWCCIdentifier - 10AE6131-1D2C-4A0A-B449-E2ACBCFF5ECD + C486FB0C-7803-4607-BCA9-799E743ECFBA IDESourceControlProjectWCConfigurations IDESourceControlRepositoryExtensionIdentifierKey public.vcs.git IDESourceControlWCCIdentifierKey - 10AE6131-1D2C-4A0A-B449-E2ACBCFF5ECD + C486FB0C-7803-4607-BCA9-799E743ECFBA IDESourceControlWCCName - MMDrawerController + MMDrawerController-GitHub From b75869c4751263c9330f10844d2aed8046c21558 Mon Sep 17 00:00:00 2001 From: Pedro Scocco Date: Wed, 28 May 2014 16:41:52 -0300 Subject: [PATCH 11/13] Fixed typo in the method name --- MMDrawerController/MMDrawerController.m | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/MMDrawerController/MMDrawerController.m b/MMDrawerController/MMDrawerController.m index 592ed8aa..2d71ad97 100644 --- a/MMDrawerController/MMDrawerController.m +++ b/MMDrawerController/MMDrawerController.m @@ -853,7 +853,7 @@ -(void)setStatusBarBackgroundViewMode:(MMStatusBarBackgroundViewMode)dummyStatus else { frame.origin.y = 0; frame.size.height = CGRectGetHeight(self.view.bounds); - [self updateStatusBarBackgroundViewAlpa]; + [self updateStatusBarBackgroundViewAlpha]; } [self setNeedsStatusBarAppearanceUpdateIfSupported]; [self.childControllerContainerView setFrame:frame]; @@ -1047,7 +1047,7 @@ -(void)setNeedsStatusBarAppearanceUpdateIfSupported{ } } -- (void)updateStatusBarBackgroundViewAlpa{ +- (void)updateStatusBarBackgroundViewAlpha{ CGFloat visibleDrawerPoints = CGRectGetMinX(self.centerContainerView.frame); CGFloat percentVisble = MAX(0.0,visibleDrawerPoints/self.maximumLeftDrawerWidth); [self updateStatusBarBackgroundViewWithAlpha:percentVisble]; From 61414d2a343f115e552a13c83a1524ab91ed5d06 Mon Sep 17 00:00:00 2001 From: Pedro Scocco Date: Wed, 28 May 2014 18:40:09 -0300 Subject: [PATCH 12/13] Added suggested changes to the README.md --- README.md | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 51c97e47..b0db1e11 100644 --- a/README.md +++ b/README.md @@ -121,9 +121,16 @@ Beginning with iOS 7, the child view controllers will by default determine the s If you do not want the drawer controller to consult the child view controllers for this state, you should subclass `MMDrawerController`, override `childViewControllerForStatusBarStyle` and `childViewControllerForStatusBarHidden`, and return nil for both. ###Custom Status Bar Background View -If you have a contrasting colors between your center view controller and your drawer controllers, the new iOS 7 status bar handling could cause your application to look less than ideal. Starting with iOS 7, `MMDrawerController` supports drawing a custom status bar area at the top of the screen, to give you an area to display the status bar with a constant color, while allowing you to drawer custom content below the status bar without worrying about the color of your navigation bars or the top of your content running up underneath the status bar. Using the feature essentially mimics <= iOS 6.X behavior. +If you have contrasting colors between your center view controller and your drawer controllers, the new iOS 7 status bar handling could cause your application to look less than ideal. Starting with iOS 7, `MMDrawerController` supports drawing a custom status bar background. You have the option to only the status bar background when opening a drawer, with a fade in animation, or to show it at all times, which mimics <= iOS 6.X behavior. -To enable a custom status bar, simple set `showsStatusBarBackgroundView` to `YES`. By default, this will draw a black a view underneath the status bar, and adjust your to content to be laid out lower than the status bar. If you would like a custom status background color, you can set `statusBarViewBackgroundColor` to whatever color you desire. +To enable a custom status bar background, simply set `statusBarBackgroundViewMode` to one of three possible modes: +* `MMStatusBarBackgroundViewModeNone` is the default value, and doesn't add any backgroud to the status bar. +* `MMStatusBarBackgroundViewModeVariable` adds a status bar background view that appears only when a drawer is open. The background view fades in as the drawer opens. +* `MMStatusBarBackgroundViewModeOpaque` adds a opaque status bar background view that appears at all times. + +Additionally, setting the old property `showsStatusBarBackgroundView` to YES will set `statusBarBackgroundViewMode` to `MMStatusBarBackgroundViewModeOpaque` and NO will set it to `MMStatusBarBackgroundViewModeNone`. + +If you would like a custom status background color, you can set `statusBarViewBackgroundColor` to whatever color you desire. --- ##Subclassing From c1c0baeac07bb33a6d26a2eba0c966638ceff24b Mon Sep 17 00:00:00 2001 From: Pedro Scocco Date: Wed, 28 May 2014 18:56:24 -0300 Subject: [PATCH 13/13] Small changes to README.md change suggestions --- README.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index b0db1e11..19dc080b 100644 --- a/README.md +++ b/README.md @@ -121,14 +121,14 @@ Beginning with iOS 7, the child view controllers will by default determine the s If you do not want the drawer controller to consult the child view controllers for this state, you should subclass `MMDrawerController`, override `childViewControllerForStatusBarStyle` and `childViewControllerForStatusBarHidden`, and return nil for both. ###Custom Status Bar Background View -If you have contrasting colors between your center view controller and your drawer controllers, the new iOS 7 status bar handling could cause your application to look less than ideal. Starting with iOS 7, `MMDrawerController` supports drawing a custom status bar background. You have the option to only the status bar background when opening a drawer, with a fade in animation, or to show it at all times, which mimics <= iOS 6.X behavior. +If you have contrasting colors between your center view controller and your drawer controllers, the new iOS 7 status bar handling could cause your application to look less than ideal. Starting with iOS 7, `MMDrawerController` supports drawing a custom status bar background. You have the option to show the status bar background only when opening a drawer, with a fade in animation, or to show it at all times, which mimics <= iOS 6.X behavior. -To enable a custom status bar background, simply set `statusBarBackgroundViewMode` to one of three possible modes: -* `MMStatusBarBackgroundViewModeNone` is the default value, and doesn't add any backgroud to the status bar. -* `MMStatusBarBackgroundViewModeVariable` adds a status bar background view that appears only when a drawer is open. The background view fades in as the drawer opens. -* `MMStatusBarBackgroundViewModeOpaque` adds a opaque status bar background view that appears at all times. +You can set `statusBarBackgroundViewMode` to one of the following modes to control the custom status bar background: +* **MMStatusBarBackgroundViewModeNone** is the default value, and doesn't add any backgroud to the status bar. +* **MMStatusBarBackgroundViewModeVariable** adds a status bar background view that appears only when a drawer is open. The background view fades in as the drawer opens. +* **MMStatusBarBackgroundViewModeOpaque** adds a opaque status bar background view that appears at all times. -Additionally, setting the old property `showsStatusBarBackgroundView` to YES will set `statusBarBackgroundViewMode` to `MMStatusBarBackgroundViewModeOpaque` and NO will set it to `MMStatusBarBackgroundViewModeNone`. +Additionally, setting the old property `showsStatusBarBackgroundView` to NO will set `statusBarBackgroundViewMode` to **MMStatusBarBackgroundViewModeNone** and YES will set it to **MMStatusBarBackgroundViewModeOpaque**. If you would like a custom status background color, you can set `statusBarViewBackgroundColor` to whatever color you desire.