Repository: mutualmobile/MMDrawerController
Branch: master
Commit: 08b153860e26
Files: 50
Total size: 310.0 KB
Directory structure:
gitextract_76l4zacj/
├── .gitignore
├── .travis.yml
├── CHANGELOG.md
├── KitchenSink/
│ ├── ExampleFiles/
│ │ ├── LaunchScreen.xib
│ │ ├── MMAppDelegate.h
│ │ ├── MMAppDelegate.m
│ │ ├── MMCenterTableViewCell.h
│ │ ├── MMCenterTableViewCell.m
│ │ ├── MMDrawerControllerKitchenSink-Info.plist
│ │ ├── MMDrawerControllerKitchenSink-Prefix.pch
│ │ ├── MMExampleCenterTableViewController.h
│ │ ├── MMExampleCenterTableViewController.m
│ │ ├── MMExampleDrawerVisualStateManager.h
│ │ ├── MMExampleDrawerVisualStateManager.m
│ │ ├── MMExampleLeftSideDrawerViewController.h
│ │ ├── MMExampleLeftSideDrawerViewController.m
│ │ ├── MMExampleRightSideDrawerViewController.h
│ │ ├── MMExampleRightSideDrawerViewController.m
│ │ ├── MMExampleSideDrawerViewController.h
│ │ ├── MMExampleSideDrawerViewController.m
│ │ ├── MMExampleViewController.h
│ │ ├── MMExampleViewController.m
│ │ ├── MMLogoView.h
│ │ ├── MMLogoView.m
│ │ ├── MMNavigationController.h
│ │ ├── MMNavigationController.m
│ │ ├── MMSideDrawerSectionHeaderView.h
│ │ ├── MMSideDrawerSectionHeaderView.m
│ │ ├── MMSideDrawerTableViewCell.h
│ │ ├── MMSideDrawerTableViewCell.m
│ │ ├── MMTableViewCell.h
│ │ ├── MMTableViewCell.m
│ │ ├── en.lproj/
│ │ │ └── InfoPlist.strings
│ │ └── main.m
│ └── MMDrawerControllerKitchenSink.xcodeproj/
│ ├── project.pbxproj
│ ├── project.xcworkspace/
│ │ ├── contents.xcworkspacedata
│ │ └── xcshareddata/
│ │ └── MMDrawerControllerKitchenSink.xccheckout
│ └── xcshareddata/
│ └── xcschemes/
│ └── MMDrawerControllerKitchenSink.xcscheme
├── LICENSE
├── MMDrawerController/
│ ├── MMDrawerBarButtonItem.h
│ ├── MMDrawerBarButtonItem.m
│ ├── MMDrawerController+Subclass.h
│ ├── MMDrawerController.h
│ ├── MMDrawerController.m
│ ├── MMDrawerVisualState.h
│ ├── MMDrawerVisualState.m
│ ├── UIViewController+MMDrawerController.h
│ └── UIViewController+MMDrawerController.m
├── MMDrawerController.podspec
└── README.md
================================================
FILE CONTENTS
================================================
================================================
FILE: .gitignore
================================================
# Xcode
.DS_Store
*/build/*
*.pbxuser
!default.pbxuser
*.mode1v3
!default.mode1v3
*.mode2v3
!default.mode2v3
*.perspectivev3
!default.perspectivev3
xcuserdata
profile
*.moved-aside
DerivedData
.idea/
*.hmap
================================================
FILE: .travis.yml
================================================
language: objective-c
script: xcodebuild -project KitchenSink/MMDrawerControllerKitchenSink.xcodeproj/ -scheme MMDrawerControllerKitchenSink -sdk iphonesimulator ONLY_ACTIVE_ARCH=NO
================================================
FILE: CHANGELOG.md
================================================
#MMDrawerController Changelog
##[0.6.0](https://github.com/mutualmobile/MMDrawerController/issues?q=milestone%3A0.6.0+is%3Aclosed) (Thursday, April 2, 2015)
###New
* **Removed iOS 6 support** ([#350](https://github.com/mutualmobile/MMDrawerController/pull/350))([#356](https://github.com/mutualmobile/MMDrawerController/pull/356)) (Kevin Harwood, podkovyrin)
* **Migrated from id to instancetype** ([#349](https://github.com/mutualmobile/MMDrawerController/pull/349)) (Kevin Harwood)
* **Added iPhone 6/6+ support to example project** ([#347](https://github.com/mutualmobile/MMDrawerController/pull/347)) (Kevin Harwood)
* **Added new properties for Shadow Radius, Shadow Opacity, Shadow Offset, Bezel Gesture Size, and Pan Velocity thresholds** Please consult the documentation for additional information. ([#294](https://github.com/mutualmobile/MMDrawerController/pull/294))([#338](https://github.com/mutualmobile/MMDrawerController/pull/338))([#270](https://github.com/mutualmobile/MMDrawerController/pull/270))([#194](https://github.com/mutualmobile/MMDrawerController/pull/194)) (SanggeonPark, lbasile, boherna, MartinMoizard)
###Fixed
* **FIXED** an issue ([#288](https://github.com/mutualmobile/MMDrawerController/pull/288)) rotation methods were called twice on iOS 8. (arielitovsky)
* **FIXED** an issue ([#348](https://github.com/mutualmobile/MMDrawerController/pull/348)) where the drawer height was incorrectly set when using a dummy status bar.
* **FIXED** an issue ([#324](https://github.com/mutualmobile/MMDrawerController/pull/324)) where we called removeFromParentViewController out of order. (long)
* **FIXED** an issue ([#306](https://github.com/mutualmobile/MMDrawerController/pull/306)) where the podspec incorrectly caused a duplicate reference warning. (klundberg)
##[0.5.7](https://github.com/mutualmobile/MMDrawerController/issues?q=milestone%3A0.5.7+is%3Aclosed) (Monday, August 25th, 2014)
###Fixed
* **FIXED** an issue ([#271](https://github.com/mutualmobile/MMDrawerController/pull/271)) where state restoration would cause multiple calls to viewDidAppear. (pronebird)
* **FIXED** an issue ([#269](https://github.com/mutualmobile/MMDrawerController/pull/269)) where an internal method name was misnamed. (shoecart)
##[0.5.6](https://github.com/mutualmobile/MMDrawerController/issues?milestone=14&page=1&state=closed) (Monday, June 9th, 2014)
###Fixed
* **FIXED** an issue ([#259](https://github.com/mutualmobile/MMDrawerController/pull/259)) where the side would rarely show up hidden when opening. (Eric Miller, Lars Anderson, Kevin Harwood)
* **FIXED** an issue ([#251](https://github.com/mutualmobile/MMDrawerController/pull/251)) where the completion block would not be called if you set the new center view controller with a full close animation while the drawer was closed. (ThuggishNuggets)
* **FIXED** an issue ([#246](https://github.com/mutualmobile/MMDrawerController/pull/246)) where user could interact with content while an animation completed. (jgallagher, Kevin Harwood)
* **FIXED** an issue ([#232](https://github.com/mutualmobile/MMDrawerController/pull/232)) where the drawer controller was not properly calling willMoveToParentViewController:nil when removing children from the drawer container view controller. (Josh Berlin, Kevin Harwood)
* **FIXED** an issue ([#222](https://github.com/mutualmobile/MMDrawerController/pull/222)) where a user interacting with during rotation would cause UI glitches. (Kevin Harwood, vkormushkin)
* **FIXED** an ([#220](https://github.com/mutualmobile/MMDrawerController/pull/220)) where we were setting the background color on the wrong view, which prevented setting a custom background color for the entire view. (Kevin Harwood, David Dulak, trawor)
##[0.5.5](https://github.com/mutualmobile/MMDrawerController/releases/tag/0.5.5) (Wednesday, April 30, 2014)
###Fixed
* **FIXED** an issue ([#244](https://github.com/mutualmobile/MMDrawerController/pull/244)) where a user could continue to interact with the view while a pan gesture animation was ongoing. (Kevin Harwood, Patrick Hernandez)
##[0.5.4](https://github.com/mutualmobile/MMDrawerController/releases/tag/0.5.4) (Tuesday, April 15, 2014)
###Fixed
* **FIXED** an issue ([#240](https://github.com/mutualmobile/MMDrawerController/pull/240)) where the center container view controller would be init'ed twice. (Lars Anderson)
* **FIXED** an issue ([#226](https://github.com/mutualmobile/MMDrawerController/pull/226)) where the side drawer would not be refreshed on a viewWill/DidAppear call. (kk-achu)
* **FIXED** an issue ([#224](https://github.com/mutualmobile/MMDrawerController/pull/224)) where we had some unreachable code. (tewha)
##[0.5.3](https://github.com/mutualmobile/MMDrawerController/releases/tag/0.5.3) (Tuesday, February 18, 2014)
###Fixed
* **FIXED** an issue ([#219](https://github.com/mutualmobile/MMDrawerController/pull/219)) where you would get an unbalanced appearance method call if you set the center view controller to the same center view controller.
##[0.5.2](https://github.com/mutualmobile/MMDrawerController/releases/tag/0.5.2) (Friday, January 31, 2014)
###New
* **Added Highlighting for iOS 7 Drawer Button Item** - Now supporting button highlighting. Also stream lined code path for iOS 6 menu button. ([#199](https://github.com/mutualmobile/MMDrawerController/pull/119)) (TomSwift)
###Fixed
* **FIXED** a Clang Analyzer issue ([#120](https://github.com/mutualmobile/MMDrawerController/pull/120)) found in Xcode 5. (klundberg)
* **FIXED** an issue ([#124](https://github.com/mutualmobile/MMDrawerController/pull/124)) where the navigation bar gestures would not work if a toolbar was displayed in the center view controller. (tbveralrud)
* **FIXED** an issue ([#152](https://github.com/mutualmobile/MMDrawerController/pull/152)) where two childControllerContainers view could be init'ed and added to the view hierarchy. (Kevin Harwood, JonasGessner)
* **FIXED** an issue ([#163](https://github.com/mutualmobile/MMDrawerController/pull/163)) where the navigation bar touch areas were smaller than they were supposed to be. (antonholmquist)
* **FIXED** an issue ([#177](https://github.com/mutualmobile/MMDrawerController/pull/177)) where disabling the shadow caused a performance issue in iOS 7. (Lars Anderson)
* **FIXED** an issue ([#211](https://github.com/mutualmobile/MMDrawerController/pull/211)) where the side drawer may become hidden if you try to interact with it during an animation. (Kevin Harwood, antonholmquist)
* **FIXED** an issue ([#212](https://github.com/mutualmobile/MMDrawerController/pull/212)) where the view controller appearance methods were not correctly send to the center view controller if you exchanged it while neither drawer was open. (Kevin Harwood, Club15CC)
##[0.5.1](https://github.com/mutualmobile/MMDrawerController/releases/tag/0.5.1) (Wednesday, September 18, 2013)
###Fixed
* **FIXED** an issue ([#110](https://github.com/mutualmobile/MMDrawerController/pull/110)) where you could not compile for iOS 6 using Xcode 4.6.3.
##[0.5.0](https://github.com/mutualmobile/MMDrawerController/releases/tag/0.5.0) (Tuesday, September 17, 2013)
###New
* **iOS 7 Support** - Compiled to work with iOS 7
* **iOS 7 Status Bar Support** - Now includes a feature to drawer an iOS 6 style status bar, allowing your drawer animations to not impact the status bar area. Consult the README or the documentation for further information.
* **MMDrawerBarButtonItem Design** - Now designed to fit in with the iOS 7 aesthetic.
* **MMDrawerBarButtonItem TintColor** - Now uses tintColor in iOS 7.
* Example project now runs in both iOS 6 and iOS 7 with two different visual designs.
###Known Issues
* iOS 7 animations transforms are a bit choppy. This issue requires further investigation, and is being tracked [here](https://github.com/mutualmobile/MMDrawerController/issues/101).
##[0.4.0](https://github.com/mutualmobile/MMDrawerController/issues?milestone=8&page=1&state=closed) (Monday, August 19, 2013)
###New
* **State Restoration Support** - `MMDrawerController` now supports state restoration, and will save the state of the open side as well. Consult the [documentation](https://github.com/mutualmobile/MMDrawerController#state-restoration) for more information. ([#69](https://github.com/mutualmobile/MMDrawerController/pull/69)). (Kevin Harwood, djibouti33)
* **Better Subclass Support** - `MMDrawerController` now contains an additional Subclass header file, to allow subclasses to access protected methods of the framework. Please consult the [documentation](https://github.com/mutualmobile/MMDrawerController#subclassing) for additional details on how to properly subclass `MMDrawerController`. ([#37](https://github.com/mutualmobile/MMDrawerController/pull/37)). (Lars Anderson)
* **initWithCoder: Support** - `MMDrawerController` now implements `initWithCoder:`, making it easier to integrate with a storyboard. Looks for an official extension from @TomSwift providing storyboard integration. ([#81](https://github.com/mutualmobile/MMDrawerController/pull/81)). (Tom Swift)
* **Improved parent drawer controller detection** - `mm_drawerController` will now walk up the entire view controller stack looking for the parent, making it easier to access the drawer controller from any child view controller in the hierarchy. ([#70](https://github.com/mutualmobile/MMDrawerController/pull/70)). (messi)
###Fixed
* **FIXED** an issue ([#66](https://github.com/mutualmobile/MMDrawerController/pull/66)) where you would get unbalanced begin/end appearance transitions when using a non-animated `setCenterViewController:...` method. (Kevin Harwood, jsankey)
* **FIXED** an issue ([#63](https://github.com/mutualmobile/MMDrawerController/pull/63)) where the visual state block received invalid transform values. (Kevin Harwood)
* **FIXED** an issue ([#71](https://github.com/mutualmobile/MMDrawerController/pull/71)) where the side drawer could become blank if you called the `closeDrawerAnimated:...` while the drawer was closing. (Kevin Harwood, Bryan Wang)
* **FIXED** an issue ([#80](https://github.com/mutualmobile/MMDrawerController/pull/80)) where the block parameters were not named appropriately. (Kevin Harwood, Joao Nunes)
##[0.3.0](https://github.com/mutualmobile/MMDrawerController/issues?milestone=6&page=1&state=closed) (Monday, July 22nd, 2013)
###New
* Added a block to determine if a gesture should be recognized, giving the implementer a chance to define where a gesture should be recognized within their views. Please consult the [README](https://github.com/mutualmobile/mmdrawercontroller#custom-gesture-recognizer-support) for additional details. ([#25](https://github.com/mutualmobile/MMDrawerController/pull/25)). (Kevin Harwood)
###Fixed
* **FIXED** an issue ([#56](https://github.com/mutualmobile/MMDrawerController/pull/56)) where the bezel gesture would be detected even if there was no drawer controller on that side. (Kevin Harwood)
* **FIXED** an issue ([#50](https://github.com/mutualmobile/MMDrawerController/pull/50)) where a subclass could get stuck in an infinite loop in the `init` method. (Tuan Cao)
##[0.2.1](https://github.com/mutualmobile/MMDrawerController/issues?milestone=7&state=closed) (Friday, June 21st, 2013)
###Fixed
* **FIXED** an issue([#42](https://github.com/mutualmobile/MMDrawerController/issues/42)) where the gesture completion block was not being called if the gesture action closed the drawer completely. (Kevin Harwood)
##[0.2.0](https://github.com/mutualmobile/MMDrawerController/issues?milestone=5&state=closed) (Tuesday, June 4th, 2013)
###New
* Added support for using the panning velocity to complete the animation. It now looks *much* better ([#18](https://github.com/mutualmobile/MMDrawerController/issues/18)). (Kevin Harwood)
* Added a new callback block to get notified when a gesture animation has completed ([#20](https://github.com/mutualmobile/MMDrawerController/issues/20)). (Kevin Harwood)
###Fixed
* **FIXED** an issue([#23](https://github.com/mutualmobile/MMDrawerController/issues/23)) where the drawer could bounce, even if a drawer was open. (Kevin Harwood)
* **FIXED** an issue([#38](https://github.com/mutualmobile/MMDrawerController/issues/38)) the designator initializer for `UIViewController` was not properly setting default values. (poteryaysya)
* **FIXED** an issue([#24](https://github.com/mutualmobile/MMDrawerController/issues/24)) where some documentation was incorrect. (Kevin Harwood)
##[0.1.0](https://github.com/mutualmobile/MMDrawerController/issues?milestone=3&page=1&state=closed) (Wednesday, May 15th, 2013)
###New
* `MMDrawerController` now properly supports full view controller containment. The drawer view controllers will properly receive their view appearance methods at the correct time now, including every time they are about to become visible. Please note that `mm_drawerWillApear` has now been deprecated. More notes below. (Kevin Harwood, Lars Anderson)
###Fixed
* **FIXED** an issue([#9](https://github.com/mutualmobile/MMDrawerController/issues/9)) where the drawer could bounce, even if no drawer was set. (Kevin Harwood)
* **FIXED** an issue([#14](https://github.com/mutualmobile/MMDrawerController/issues/14)) where open center interaction state could be incorrectly applied if a new view controller is pushed onto a center view controller when a drawer is open. (Kevin Harwood)
###Deprecated
* Support for the `mm_drawerWillAppear` method in the `UIViewController+MMDrawerController` category is no longer available. Please move any logic contained within this method to `viewWillAppear:` in your drawer view controllers. This method will no longer be called going forward.
##[0.0.2](https://github.com/mutualmobile/MMDrawerController/issues?milestone=2&state=closed) (Thursday, May 9th, 2013)
###New
* Improved the example to allow you to disable the left or right side drawer controller. (Kevin Harwood)
###Fixed
* **FIXED** an issue([#6](https://github.com/mutualmobile/MMDrawerController/issues/1)) where hidden side drawer controllers received touches if the center view controller was set to userInteraction NO. (Kevin Harwood)
* **FIXED** an issue([#1](https://github.com/mutualmobile/MMDrawerController/issues/1)) where `shouldStretchDrawer` caused drawer controllers with only one side drawer to stretch in the wrong direction (Lars Anderson, Kevin Harwood)
##0.0.1 (Wednesday, May 8th, 2013)
* Initial Library Release
================================================
FILE: KitchenSink/ExampleFiles/LaunchScreen.xib
================================================
================================================
FILE: KitchenSink/ExampleFiles/MMAppDelegate.h
================================================
// Copyright (c) 2013 Mutual Mobile (http://mutualmobile.com/)
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
#import
@interface MMAppDelegate : UIResponder
@property (strong, nonatomic) UIWindow *window;
@end
================================================
FILE: KitchenSink/ExampleFiles/MMAppDelegate.m
================================================
// Copyright (c) 2013 Mutual Mobile (http://mutualmobile.com/)
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
#import "MMAppDelegate.h"
#import "MMDrawerController.h"
#import "MMExampleCenterTableViewController.h"
#import "MMExampleLeftSideDrawerViewController.h"
#import "MMExampleRightSideDrawerViewController.h"
#import "MMDrawerVisualState.h"
#import "MMExampleDrawerVisualStateManager.h"
#import "MMNavigationController.h"
#import
@interface MMAppDelegate ()
@property (nonatomic,strong) MMDrawerController * drawerController;
@end
@implementation MMAppDelegate
-(BOOL)application:(UIApplication *)application willFinishLaunchingWithOptions:(NSDictionary *)launchOptions{
UIViewController * leftSideDrawerViewController = [[MMExampleLeftSideDrawerViewController alloc] init];
UIViewController * centerViewController = [[MMExampleCenterTableViewController alloc] init];
UIViewController * rightSideDrawerViewController = [[MMExampleRightSideDrawerViewController alloc] init];
UINavigationController * navigationController = [[MMNavigationController alloc] initWithRootViewController:centerViewController];
[navigationController setRestorationIdentifier:@"MMExampleCenterNavigationControllerRestorationKey"];
UINavigationController * rightSideNavController = [[MMNavigationController alloc] initWithRootViewController:rightSideDrawerViewController];
[rightSideNavController setRestorationIdentifier:@"MMExampleRightNavigationControllerRestorationKey"];
UINavigationController * leftSideNavController = [[MMNavigationController alloc] initWithRootViewController:leftSideDrawerViewController];
[leftSideNavController setRestorationIdentifier:@"MMExampleLeftNavigationControllerRestorationKey"];
self.drawerController = [[MMDrawerController alloc]
initWithCenterViewController:navigationController
leftDrawerViewController:leftSideNavController
rightDrawerViewController:rightSideNavController];
[self.drawerController setShowsShadow:NO];
[self.drawerController setRestorationIdentifier:@"MMDrawer"];
[self.drawerController setMaximumRightDrawerWidth:200.0];
[self.drawerController setOpenDrawerGestureModeMask:MMOpenDrawerGestureModeAll];
[self.drawerController setCloseDrawerGestureModeMask:MMCloseDrawerGestureModeAll];
[self.drawerController
setDrawerVisualStateBlock:^(MMDrawerController *drawerController, MMDrawerSide drawerSide, CGFloat percentVisible) {
MMDrawerControllerDrawerVisualStateBlock block;
block = [[MMExampleDrawerVisualStateManager sharedManager]
drawerVisualStateBlockForDrawerSide:drawerSide];
if(block){
block(drawerController, drawerSide, percentVisible);
}
}];
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
UIColor * tintColor = [UIColor colorWithRed:29.0/255.0
green:173.0/255.0
blue:234.0/255.0
alpha:1.0];
[self.window setTintColor:tintColor];
[self.window setRootViewController:self.drawerController];
return YES;
}
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window.backgroundColor = [UIColor whiteColor];
[self.window makeKeyAndVisible];
return YES;
}
- (BOOL)application:(UIApplication *)application shouldSaveApplicationState:(NSCoder *)coder{
return YES;
}
- (BOOL)application:(UIApplication *)application shouldRestoreApplicationState:(NSCoder *)coder{
return YES;
}
- (UIViewController *)application:(UIApplication *)application viewControllerWithRestorationIdentifierPath:(NSArray *)identifierComponents coder:(NSCoder *)coder
{
NSString * key = [identifierComponents lastObject];
if([key isEqualToString:@"MMDrawer"]){
return self.window.rootViewController;
}
else if ([key isEqualToString:@"MMExampleCenterNavigationControllerRestorationKey"]) {
return ((MMDrawerController *)self.window.rootViewController).centerViewController;
}
else if ([key isEqualToString:@"MMExampleRightNavigationControllerRestorationKey"]) {
return ((MMDrawerController *)self.window.rootViewController).rightDrawerViewController;
}
else if ([key isEqualToString:@"MMExampleLeftNavigationControllerRestorationKey"]) {
return ((MMDrawerController *)self.window.rootViewController).leftDrawerViewController;
}
else if ([key isEqualToString:@"MMExampleLeftSideDrawerController"]){
UIViewController * leftVC = ((MMDrawerController *)self.window.rootViewController).leftDrawerViewController;
if([leftVC isKindOfClass:[UINavigationController class]]){
return [(UINavigationController*)leftVC topViewController];
}
else {
return leftVC;
}
}
else if ([key isEqualToString:@"MMExampleRightSideDrawerController"]){
UIViewController * rightVC = ((MMDrawerController *)self.window.rootViewController).rightDrawerViewController;
if([rightVC isKindOfClass:[UINavigationController class]]){
return [(UINavigationController*)rightVC topViewController];
}
else {
return rightVC;
}
}
return nil;
}
@end
================================================
FILE: KitchenSink/ExampleFiles/MMCenterTableViewCell.h
================================================
// Copyright (c) 2013 Mutual Mobile (http://mutualmobile.com/)
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
#import "MMTableViewCell.h"
@interface MMCenterTableViewCell : MMTableViewCell
@end
================================================
FILE: KitchenSink/ExampleFiles/MMCenterTableViewCell.m
================================================
// Copyright (c) 2013 Mutual Mobile (http://mutualmobile.com/)
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
#import "MMCenterTableViewCell.h"
@implementation MMCenterTableViewCell
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
if (self) {
[self setAccessoryCheckmarkColor:[UIColor colorWithRed:13.0/255.0
green:88.0/255.0
blue:161.0/255.0
alpha:1.0]];
}
return self;
}
-(void)updateContentForNewContentSize{
if([[UIFont class] respondsToSelector:@selector(preferredFontForTextStyle:)]){
[self.textLabel setFont:[UIFont preferredFontForTextStyle:UIFontTextStyleBody]];
}
}
@end
================================================
FILE: KitchenSink/ExampleFiles/MMDrawerControllerKitchenSink-Info.plist
================================================
CFBundleDevelopmentRegionenCFBundleDisplayNameMMDrawerCFBundleExecutable${EXECUTABLE_NAME}CFBundleIconFilesIcon.pngIcon@2x.pngIcon-72.pngIcon-72@2x.pngCFBundleIdentifiercom.mutualmobile.mmsdcvc.${PRODUCT_NAME:rfc1034identifier}CFBundleInfoDictionaryVersion6.0CFBundleName${PRODUCT_NAME}CFBundlePackageTypeAPPLCFBundleShortVersionString1.0.0CFBundleSignature????CFBundleVersion1.0.0LSRequiresIPhoneOSUILaunchStoryboardNameLaunchScreenUIPrerenderedIconUIRequiredDeviceCapabilitiesarmv7UIStatusBarStyleUIStatusBarStyleBlackOpaqueUISupportedInterfaceOrientationsUIInterfaceOrientationPortraitUIInterfaceOrientationLandscapeLeftUIInterfaceOrientationLandscapeRightUISupportedInterfaceOrientations~ipadUIInterfaceOrientationPortraitUIInterfaceOrientationPortraitUpsideDownUIInterfaceOrientationLandscapeLeftUIInterfaceOrientationLandscapeRightUIViewControllerBasedStatusAppearance
================================================
FILE: KitchenSink/ExampleFiles/MMDrawerControllerKitchenSink-Prefix.pch
================================================
//
// Prefix header for all source files of the 'MMDrawerController' target in the 'MMDrawerController' project
//
#import
#ifndef __IPHONE_3_0
#warning "This project uses features only available in iOS SDK 3.0 and later."
#endif
#ifdef __OBJC__
#import
#import
#endif
================================================
FILE: KitchenSink/ExampleFiles/MMExampleCenterTableViewController.h
================================================
// Copyright (c) 2013 Mutual Mobile (http://mutualmobile.com/)
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
#import
#import "MMExampleViewController.h"
@interface MMExampleCenterTableViewController : MMExampleViewController
@property (nonatomic,strong) UITableView * tableView;
@end
================================================
FILE: KitchenSink/ExampleFiles/MMExampleCenterTableViewController.m
================================================
// Copyright (c) 2013 Mutual Mobile (http://mutualmobile.com/)
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
#import "MMExampleCenterTableViewController.h"
#import "MMExampleDrawerVisualStateManager.h"
#import "UIViewController+MMDrawerController.h"
#import "MMDrawerBarButtonItem.h"
#import "MMLogoView.h"
#import "MMCenterTableViewCell.h"
#import "MMExampleLeftSideDrawerViewController.h"
#import "MMExampleRightSideDrawerViewController.h"
#import "MMNavigationController.h"
#import
typedef NS_ENUM(NSInteger, MMCenterViewControllerSection){
MMCenterViewControllerSectionLeftViewState,
MMCenterViewControllerSectionLeftDrawerAnimation,
MMCenterViewControllerSectionRightViewState,
MMCenterViewControllerSectionRightDrawerAnimation,
};
@interface MMExampleCenterTableViewController ()
@end
@implementation MMExampleCenterTableViewController
- (id)init
{
self = [super init];
if (self) {
[self setRestorationIdentifier:@"MMExampleCenterControllerRestorationKey"];
}
return self;
}
- (void)viewDidLoad
{
[super viewDidLoad];
_tableView = [[UITableView alloc] initWithFrame:self.view.bounds style:UITableViewStyleGrouped];
[self.tableView setDelegate:self];
[self.tableView setDataSource:self];
[self.view addSubview:self.tableView];
[self.tableView setAutoresizingMask:UIViewAutoresizingFlexibleWidth|UIViewAutoresizingFlexibleHeight];
UITapGestureRecognizer * doubleTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(doubleTap:)];
[doubleTap setNumberOfTapsRequired:2];
[self.view addGestureRecognizer:doubleTap];
UITapGestureRecognizer * twoFingerDoubleTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(twoFingerDoubleTap:)];
[twoFingerDoubleTap setNumberOfTapsRequired:2];
[twoFingerDoubleTap setNumberOfTouchesRequired:2];
[self.view addGestureRecognizer:twoFingerDoubleTap];
[self setupLeftMenuButton];
[self setupRightMenuButton];
UIColor * barColor = [UIColor
colorWithRed:247.0/255.0
green:249.0/255.0
blue:250.0/255.0
alpha:1.0];
[self.navigationController.navigationBar setBarTintColor:barColor];
MMLogoView * logo = [[MMLogoView alloc] initWithFrame:CGRectMake(0, 0, 29, 31)];
[self.navigationItem setTitleView:logo];
[self.navigationController.view.layer setCornerRadius:10.0f];
UIView *backView = [[UIView alloc] init];
[backView setBackgroundColor:[UIColor colorWithRed:208.0/255.0
green:208.0/255.0
blue:208.0/255.0
alpha:1.0]];
[self.tableView setBackgroundView:backView];
}
-(void)viewWillAppear:(BOOL)animated{
[super viewWillAppear:animated];
NSLog(@"Center will appear");
}
-(void)viewDidAppear:(BOOL)animated{
[super viewDidAppear:animated];
NSLog(@"Center did appear");
}
-(void)viewWillDisappear:(BOOL)animated{
[super viewWillDisappear:animated];
NSLog(@"Center will disappear");
}
-(void)viewDidDisappear:(BOOL)animated{
[super viewDidDisappear:animated];
NSLog(@"Center did disappear");
}
-(void)setupLeftMenuButton{
MMDrawerBarButtonItem * leftDrawerButton = [[MMDrawerBarButtonItem alloc] initWithTarget:self action:@selector(leftDrawerButtonPress:)];
[self.navigationItem setLeftBarButtonItem:leftDrawerButton animated:YES];
}
-(void)setupRightMenuButton{
MMDrawerBarButtonItem * rightDrawerButton = [[MMDrawerBarButtonItem alloc] initWithTarget:self action:@selector(rightDrawerButtonPress:)];
[self.navigationItem setRightBarButtonItem:rightDrawerButton animated:YES];
}
-(void)contentSizeDidChange:(NSString *)size{
[self.tableView reloadData];
}
#pragma mark - Table view data source
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return 4;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
// Return the number of rows in the section.
switch (section) {
case MMCenterViewControllerSectionLeftDrawerAnimation:
case MMCenterViewControllerSectionRightDrawerAnimation:
return 5;
case MMCenterViewControllerSectionLeftViewState:
case MMCenterViewControllerSectionRightViewState:
return 1;
default:
return 0;
}
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[MMCenterTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
[cell setSelectionStyle:UITableViewCellSelectionStyleGray];
}
UIColor * selectedColor = [UIColor
colorWithRed:1.0/255.0
green:15.0/255.0
blue:25.0/255.0
alpha:1.0];
UIColor * unselectedColor = [UIColor
colorWithRed:79.0/255.0
green:93.0/255.0
blue:102.0/255.0
alpha:1.0];
switch (indexPath.section) {
case MMCenterViewControllerSectionLeftDrawerAnimation:
case MMCenterViewControllerSectionRightDrawerAnimation:{
MMDrawerAnimationType animationTypeForSection;
if(indexPath.section == MMCenterViewControllerSectionLeftDrawerAnimation){
animationTypeForSection = [[MMExampleDrawerVisualStateManager sharedManager] leftDrawerAnimationType];
}
else {
animationTypeForSection = [[MMExampleDrawerVisualStateManager sharedManager] rightDrawerAnimationType];
}
if(animationTypeForSection == indexPath.row){
[cell setAccessoryType:UITableViewCellAccessoryCheckmark];
[cell.textLabel setTextColor:selectedColor];
}
else {
[cell setAccessoryType:UITableViewCellAccessoryNone];
[cell.textLabel setTextColor:unselectedColor];
}
switch (indexPath.row) {
case MMDrawerAnimationTypeNone:
[cell.textLabel setText:@"None"];
break;
case MMDrawerAnimationTypeSlide:
[cell.textLabel setText:@"Slide"];
break;
case MMDrawerAnimationTypeSlideAndScale:
[cell.textLabel setText:@"Slide and Scale"];
break;
case MMDrawerAnimationTypeSwingingDoor:
[cell.textLabel setText:@"Swinging Door"];
break;
case MMDrawerAnimationTypeParallax:
[cell.textLabel setText:@"Parallax"];
break;
default:
break;
}
break;
}
case MMCenterViewControllerSectionLeftViewState:{
[cell.textLabel setText:@"Enabled"];
if(self.mm_drawerController.leftDrawerViewController){
[cell setAccessoryType:UITableViewCellAccessoryCheckmark];
[cell.textLabel setTextColor:selectedColor];
}
else{
[cell setAccessoryType:UITableViewCellAccessoryNone];
[cell.textLabel setTextColor:unselectedColor];
}
break;
}
case MMCenterViewControllerSectionRightViewState:{
[cell.textLabel setText:@"Enabled"];
if(self.mm_drawerController.rightDrawerViewController){
[cell setAccessoryType:UITableViewCellAccessoryCheckmark];
[cell.textLabel setTextColor:selectedColor];
}
else{
[cell setAccessoryType:UITableViewCellAccessoryNone];
[cell.textLabel setTextColor:unselectedColor];
}
break;
}
default:
break;
}
return cell;
}
-(NSString*)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section{
switch (section) {
case MMCenterViewControllerSectionLeftDrawerAnimation:
return @"Left Drawer Animation";
case MMCenterViewControllerSectionRightDrawerAnimation:
return @"Right Drawer Animation";
case MMCenterViewControllerSectionLeftViewState:
return @"Left Drawer";
case MMCenterViewControllerSectionRightViewState:
return @"Right Drawer";
default:
return nil;
}
}
#pragma mark - Table view delegate
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
switch (indexPath.section) {
case MMCenterViewControllerSectionLeftDrawerAnimation:
case MMCenterViewControllerSectionRightDrawerAnimation:{
if(indexPath.section == MMCenterViewControllerSectionLeftDrawerAnimation){
[[MMExampleDrawerVisualStateManager sharedManager] setLeftDrawerAnimationType:indexPath.row];
}
else {
[[MMExampleDrawerVisualStateManager sharedManager] setRightDrawerAnimationType:indexPath.row];
}
[tableView reloadSections:[NSIndexSet indexSetWithIndex:indexPath.section] withRowAnimation:UITableViewRowAnimationNone];
[tableView selectRowAtIndexPath:indexPath animated:NO scrollPosition:UITableViewScrollPositionNone];
[tableView deselectRowAtIndexPath:indexPath animated:YES];
break;
}
case MMCenterViewControllerSectionLeftViewState:
case MMCenterViewControllerSectionRightViewState:{
UIViewController * sideDrawerViewController;
MMDrawerSide drawerSide = MMDrawerSideNone;
if(indexPath.section == MMCenterViewControllerSectionLeftViewState){
sideDrawerViewController = self.mm_drawerController.leftDrawerViewController;
drawerSide = MMDrawerSideLeft;
}
else if(indexPath.section == MMCenterViewControllerSectionRightViewState){
sideDrawerViewController = self.mm_drawerController.rightDrawerViewController;
drawerSide = MMDrawerSideRight;
}
if(sideDrawerViewController){
[self.mm_drawerController
closeDrawerAnimated:YES
completion:^(BOOL finished) {
if(drawerSide == MMDrawerSideLeft){
[self.mm_drawerController setLeftDrawerViewController:nil];
[self.navigationItem setLeftBarButtonItems:nil animated:YES];
}
else if(drawerSide == MMDrawerSideRight){
[self.mm_drawerController setRightDrawerViewController:nil];
[self.navigationItem setRightBarButtonItem:nil animated:YES];
}
[tableView reloadRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationNone];
[tableView selectRowAtIndexPath:indexPath animated:NO scrollPosition:UITableViewScrollPositionNone];
[tableView deselectRowAtIndexPath:indexPath animated:YES];
}];
}
else {
if(drawerSide == MMDrawerSideLeft){
UIViewController * vc = [[MMExampleLeftSideDrawerViewController alloc] init];
UINavigationController * navC = [[MMNavigationController alloc] initWithRootViewController:vc];
[self.mm_drawerController setLeftDrawerViewController:navC];
[self setupLeftMenuButton];
}
else if(drawerSide == MMDrawerSideRight){
UIViewController * vc = [[MMExampleRightSideDrawerViewController alloc] init];
UINavigationController * navC = [[MMNavigationController alloc] initWithRootViewController:vc];
[self.mm_drawerController setRightDrawerViewController:navC];
[self setupRightMenuButton];
}
[tableView reloadRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationNone];
[tableView selectRowAtIndexPath:indexPath animated:NO scrollPosition:UITableViewScrollPositionNone];
[tableView deselectRowAtIndexPath:indexPath animated:YES];
}
break;
}
default:
break;
}
}
#pragma mark - Button Handlers
-(void)leftDrawerButtonPress:(id)sender{
[self.mm_drawerController toggleDrawerSide:MMDrawerSideLeft animated:YES completion:nil];
}
-(void)rightDrawerButtonPress:(id)sender{
[self.mm_drawerController toggleDrawerSide:MMDrawerSideRight animated:YES completion:nil];
}
-(void)doubleTap:(UITapGestureRecognizer*)gesture{
[self.mm_drawerController bouncePreviewForDrawerSide:MMDrawerSideLeft completion:nil];
}
-(void)twoFingerDoubleTap:(UITapGestureRecognizer*)gesture{
[self.mm_drawerController bouncePreviewForDrawerSide:MMDrawerSideRight completion:nil];
}
@end
================================================
FILE: KitchenSink/ExampleFiles/MMExampleDrawerVisualStateManager.h
================================================
// Copyright (c) 2013 Mutual Mobile (http://mutualmobile.com/)
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
#import
#import "MMDrawerVisualState.h"
typedef NS_ENUM(NSInteger, MMDrawerAnimationType){
MMDrawerAnimationTypeNone,
MMDrawerAnimationTypeSlide,
MMDrawerAnimationTypeSlideAndScale,
MMDrawerAnimationTypeSwingingDoor,
MMDrawerAnimationTypeParallax,
};
@interface MMExampleDrawerVisualStateManager : NSObject
@property (nonatomic,assign) MMDrawerAnimationType leftDrawerAnimationType;
@property (nonatomic,assign) MMDrawerAnimationType rightDrawerAnimationType;
+ (MMExampleDrawerVisualStateManager *)sharedManager;
-(MMDrawerControllerDrawerVisualStateBlock)drawerVisualStateBlockForDrawerSide:(MMDrawerSide)drawerSide;
@end
================================================
FILE: KitchenSink/ExampleFiles/MMExampleDrawerVisualStateManager.m
================================================
// Copyright (c) 2013 Mutual Mobile (http://mutualmobile.com/)
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
#import "MMExampleDrawerVisualStateManager.h"
#import
@implementation MMExampleDrawerVisualStateManager
+ (MMExampleDrawerVisualStateManager *)sharedManager {
static MMExampleDrawerVisualStateManager *_sharedManager = nil;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
_sharedManager = [[MMExampleDrawerVisualStateManager alloc] init];
[_sharedManager setLeftDrawerAnimationType:MMDrawerAnimationTypeParallax];
[_sharedManager setRightDrawerAnimationType:MMDrawerAnimationTypeParallax];
});
return _sharedManager;
}
-(MMDrawerControllerDrawerVisualStateBlock)drawerVisualStateBlockForDrawerSide:(MMDrawerSide)drawerSide{
MMDrawerAnimationType animationType;
if(drawerSide == MMDrawerSideLeft){
animationType = self.leftDrawerAnimationType;
}
else {
animationType = self.rightDrawerAnimationType;
}
MMDrawerControllerDrawerVisualStateBlock visualStateBlock = nil;
switch (animationType) {
case MMDrawerAnimationTypeSlide:
visualStateBlock = [MMDrawerVisualState slideVisualStateBlock];
break;
case MMDrawerAnimationTypeSlideAndScale:
visualStateBlock = [MMDrawerVisualState slideAndScaleVisualStateBlock];
break;
case MMDrawerAnimationTypeParallax:
visualStateBlock = [MMDrawerVisualState parallaxVisualStateBlockWithParallaxFactor:2.0];
break;
case MMDrawerAnimationTypeSwingingDoor:
visualStateBlock = [MMDrawerVisualState swingingDoorVisualStateBlock];
break;
default:
visualStateBlock = ^(MMDrawerController * drawerController, MMDrawerSide drawerSide, CGFloat percentVisible){
UIViewController * sideDrawerViewController;
CATransform3D transform;
CGFloat maxDrawerWidth;
if(drawerSide == MMDrawerSideLeft){
sideDrawerViewController = drawerController.leftDrawerViewController;
maxDrawerWidth = drawerController.maximumLeftDrawerWidth;
}
else if(drawerSide == MMDrawerSideRight){
sideDrawerViewController = drawerController.rightDrawerViewController;
maxDrawerWidth = drawerController.maximumRightDrawerWidth;
}
if(percentVisible > 1.0){
transform = CATransform3DMakeScale(percentVisible, 1.f, 1.f);
if(drawerSide == MMDrawerSideLeft){
transform = CATransform3DTranslate(transform, maxDrawerWidth*(percentVisible-1.f)/2, 0.f, 0.f);
}else if(drawerSide == MMDrawerSideRight){
transform = CATransform3DTranslate(transform, -maxDrawerWidth*(percentVisible-1.f)/2, 0.f, 0.f);
}
}
else {
transform = CATransform3DIdentity;
}
[sideDrawerViewController.view.layer setTransform:transform];
};
break;
}
return visualStateBlock;
}
@end
================================================
FILE: KitchenSink/ExampleFiles/MMExampleLeftSideDrawerViewController.h
================================================
// Copyright (c) 2013 Mutual Mobile (http://mutualmobile.com/)
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
#import "MMExampleSideDrawerViewController.h"
@interface MMExampleLeftSideDrawerViewController : MMExampleSideDrawerViewController
@end
================================================
FILE: KitchenSink/ExampleFiles/MMExampleLeftSideDrawerViewController.m
================================================
// Copyright (c) 2013 Mutual Mobile (http://mutualmobile.com/)
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
#import "MMExampleLeftSideDrawerViewController.h"
#import "MMTableViewCell.h"
@interface MMExampleLeftSideDrawerViewController ()
@end
@implementation MMExampleLeftSideDrawerViewController
-(id)init{
self = [super init];
if(self){
[self setRestorationIdentifier:@"MMExampleLeftSideDrawerController"];
}
return self;
}
-(void)viewWillAppear:(BOOL)animated{
[super viewWillAppear:animated];
NSLog(@"Left will appear");
}
-(void)viewDidAppear:(BOOL)animated{
[super viewDidAppear:animated];
NSLog(@"Left did appear");
}
-(void)viewWillDisappear:(BOOL)animated{
[super viewWillDisappear:animated];
NSLog(@"Left will disappear");
}
-(void)viewDidDisappear:(BOOL)animated{
[super viewDidDisappear:animated];
NSLog(@"Left did disappear");
}
-(void)viewDidLoad{
[super viewDidLoad];
[self setTitle:@"Left Drawer"];
}
-(NSString*)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section{
if(section == MMDrawerSectionDrawerWidth)
return @"Left Drawer Width";
else
return [super tableView:tableView titleForHeaderInSection:section];
}
-(UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
UITableViewCell * cell = [super tableView:tableView cellForRowAtIndexPath:indexPath];
if(indexPath.section == MMDrawerSectionDrawerWidth){
CGFloat width = [self.drawerWidths[indexPath.row] intValue];
CGFloat drawerWidth = self.mm_drawerController.maximumLeftDrawerWidth;
if(drawerWidth == width){
[cell setAccessoryType:UITableViewCellAccessoryCheckmark];
}
else{
[cell setAccessoryType:UITableViewCellAccessoryNone];
}
[cell.textLabel setText:[NSString stringWithFormat:@"Width %d",[self.drawerWidths[indexPath.row] intValue]]];
}
return cell;
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
if(indexPath.section == MMDrawerSectionDrawerWidth){
[self.mm_drawerController
setMaximumLeftDrawerWidth:[self.drawerWidths[indexPath.row] floatValue]
animated:YES
completion:^(BOOL finished) {
[tableView reloadSections:[NSIndexSet indexSetWithIndex:indexPath.section] withRowAnimation:UITableViewRowAnimationNone];
[tableView selectRowAtIndexPath:indexPath animated:NO scrollPosition:UITableViewScrollPositionNone];
[tableView deselectRowAtIndexPath:indexPath animated:YES];
}];
}
else {
[super tableView:tableView didSelectRowAtIndexPath:indexPath];
}
}
@end
================================================
FILE: KitchenSink/ExampleFiles/MMExampleRightSideDrawerViewController.h
================================================
// Copyright (c) 2013 Mutual Mobile (http://mutualmobile.com/)
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
#import "MMExampleSideDrawerViewController.h"
@interface MMExampleRightSideDrawerViewController : MMExampleSideDrawerViewController
@end
================================================
FILE: KitchenSink/ExampleFiles/MMExampleRightSideDrawerViewController.m
================================================
// Copyright (c) 2013 Mutual Mobile (http://mutualmobile.com/)
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
#import "MMExampleRightSideDrawerViewController.h"
@interface MMExampleRightSideDrawerViewController ()
@end
@implementation MMExampleRightSideDrawerViewController
-(id)init{
self = [super init];
if(self){
[self setRestorationIdentifier:@"MMExampleRightSideDrawerController"];
}
return self;
}
-(void)viewWillAppear:(BOOL)animated{
[super viewWillAppear:animated];
NSLog(@"Right will appear");
}
-(void)viewDidAppear:(BOOL)animated{
[super viewDidAppear:animated];
NSLog(@"Right did appear");
}
-(void)viewWillDisappear:(BOOL)animated{
[super viewWillDisappear:animated];
NSLog(@"Right will disappear");
}
-(void)viewDidDisappear:(BOOL)animated{
[super viewDidDisappear:animated];
NSLog(@"Right did disappear");
}
-(void)viewDidLoad{
[super viewDidLoad];
[self setTitle:@"Right Drawer"];
}
-(NSString*)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section{
if(section == MMDrawerSectionDrawerWidth)
return @"Right Drawer Width";
else
return [super tableView:tableView titleForHeaderInSection:section];
}
-(UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
UITableViewCell * cell = [super tableView:tableView cellForRowAtIndexPath:indexPath];
if(indexPath.section == MMDrawerSectionDrawerWidth){
CGFloat width = [self.drawerWidths[indexPath.row] intValue];
CGFloat drawerWidth = self.mm_drawerController.maximumRightDrawerWidth;
if(drawerWidth == width)
[cell setAccessoryType:UITableViewCellAccessoryCheckmark];
else
[cell setAccessoryType:UITableViewCellAccessoryNone];
[cell.textLabel setText:[NSString stringWithFormat:@"Width %d",[self.drawerWidths[indexPath.row] intValue]]];
}
return cell;
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
if(indexPath.section == MMDrawerSectionDrawerWidth){
[self.mm_drawerController
setMaximumRightDrawerWidth:[self.drawerWidths[indexPath.row] floatValue]
animated:YES
completion:^(BOOL finished) {
[tableView reloadSections:[NSIndexSet indexSetWithIndex:indexPath.section] withRowAnimation:UITableViewRowAnimationNone];
[tableView selectRowAtIndexPath:indexPath animated:NO scrollPosition:UITableViewScrollPositionNone];
[tableView deselectRowAtIndexPath:indexPath animated:YES];
}];
}
else {
[super tableView:tableView didSelectRowAtIndexPath:indexPath];
}
}
@end
================================================
FILE: KitchenSink/ExampleFiles/MMExampleSideDrawerViewController.h
================================================
// Copyright (c) 2013 Mutual Mobile (http://mutualmobile.com/)
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
#import
#import "UIViewController+MMDrawerController.h"
#import "MMExampleViewController.h"
typedef NS_ENUM(NSInteger, MMDrawerSection){
MMDrawerSectionViewSelection,
MMDrawerSectionDrawerWidth,
MMDrawerSectionShadowToggle,
MMDrawerSectionOpenDrawerGestures,
MMDrawerSectionCloseDrawerGestures,
MMDrawerSectionCenterHiddenInteraction,
MMDrawerSectionStretchDrawer,
};
@interface MMExampleSideDrawerViewController : MMExampleViewController
@property (nonatomic, strong) UITableView * tableView;
@property (nonatomic,strong) NSArray * drawerWidths;
@end
================================================
FILE: KitchenSink/ExampleFiles/MMExampleSideDrawerViewController.m
================================================
// Copyright (c) 2013 Mutual Mobile (http://mutualmobile.com/)
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
#import "MMExampleSideDrawerViewController.h"
#import "MMExampleCenterTableViewController.h"
#import "MMSideDrawerTableViewCell.h"
#import "MMSideDrawerSectionHeaderView.h"
#import "MMLogoView.h"
#import "MMNavigationController.h"
@implementation MMExampleSideDrawerViewController
- (void)viewDidLoad
{
[super viewDidLoad];
_tableView = [[UITableView alloc] initWithFrame:self.view.bounds style:UITableViewStyleGrouped];
[self.tableView setDelegate:self];
[self.tableView setDataSource:self];
[self.view addSubview:self.tableView];
[self.tableView setAutoresizingMask:UIViewAutoresizingFlexibleWidth|UIViewAutoresizingFlexibleHeight];
UIColor * tableViewBackgroundColor;
tableViewBackgroundColor = [UIColor colorWithRed:110.0/255.0
green:113.0/255.0
blue:115.0/255.0
alpha:1.0];
[self.tableView setBackgroundColor:tableViewBackgroundColor];
[self.tableView setSeparatorStyle:UITableViewCellSeparatorStyleNone];
[self.view setBackgroundColor:[UIColor colorWithRed:66.0/255.0
green:69.0/255.0
blue:71.0/255.0
alpha:1.0]];
UIColor * barColor = [UIColor colorWithRed:161.0/255.0
green:164.0/255.0
blue:166.0/255.0
alpha:1.0];
if([self.navigationController.navigationBar respondsToSelector:@selector(setBarTintColor:)]){
[self.navigationController.navigationBar setBarTintColor:barColor];
}
else {
[self.navigationController.navigationBar setTintColor:barColor];
}
NSDictionary *navBarTitleDict;
UIColor * titleColor = [UIColor colorWithRed:55.0/255.0
green:70.0/255.0
blue:77.0/255.0
alpha:1.0];
navBarTitleDict = @{NSForegroundColorAttributeName:titleColor};
[self.navigationController.navigationBar setTitleTextAttributes:navBarTitleDict];
self.drawerWidths = @[@(160),@(200),@(240),@(280),@(320)];
CGSize logoSize = CGSizeMake(58, 62);
MMLogoView * logo = [[MMLogoView alloc] initWithFrame:CGRectMake(CGRectGetMidX(self.tableView.bounds)-logoSize.width/2.0,
-logoSize.height-logoSize.height/4.0,
logoSize.width,
logoSize.height)];
[logo setAutoresizingMask:UIViewAutoresizingFlexibleLeftMargin|UIViewAutoresizingFlexibleRightMargin];
[self.tableView addSubview:logo];
[self.view setBackgroundColor:[UIColor clearColor]];
}
-(void)viewWillAppear:(BOOL)animated{
[super viewWillAppear:animated];
[self.tableView reloadSections:[NSIndexSet indexSetWithIndexesInRange:NSMakeRange(0, self.tableView.numberOfSections-1)] withRowAnimation:UITableViewRowAnimationNone];
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
-(void)contentSizeDidChange:(NSString *)size{
[self.tableView reloadData];
}
#pragma mark - Table view data source
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
// Return the number of sections.
return 7;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
// Return the number of rows in the section.
switch (section) {
case MMDrawerSectionViewSelection:
return 2;
case MMDrawerSectionDrawerWidth:
return self.drawerWidths.count;
case MMDrawerSectionShadowToggle:
return 1;
case MMDrawerSectionOpenDrawerGestures:
return 3;
case MMDrawerSectionCloseDrawerGestures:
return 6;
case MMDrawerSectionCenterHiddenInteraction:
return 3;
case MMDrawerSectionStretchDrawer:
return 1;
default:
return 0;
}
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = (UITableViewCell*)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[MMSideDrawerTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
[cell setSelectionStyle:UITableViewCellSelectionStyleBlue];
}
switch (indexPath.section) {
case MMDrawerSectionViewSelection:
if(indexPath.row == 0){
[cell.textLabel setText:@"Quick View Change"];
}
else {
[cell.textLabel setText:@"Full View Change"];
}
[cell setAccessoryType:UITableViewCellAccessoryDisclosureIndicator];
break;
case MMDrawerSectionDrawerWidth:{
//Implement in Subclass
break;
}
case MMDrawerSectionShadowToggle:{
[cell.textLabel setText:@"Show Shadow"];
if(self.mm_drawerController.showsShadow)
[cell setAccessoryType:UITableViewCellAccessoryCheckmark];
else
[cell setAccessoryType:UITableViewCellAccessoryNone];
break;
}
case MMDrawerSectionOpenDrawerGestures:{
switch (indexPath.row) {
case 0:
[cell.textLabel setText:@"Pan Nav Bar"];
if((self.mm_drawerController.openDrawerGestureModeMask&MMOpenDrawerGestureModePanningNavigationBar)>0)
[cell setAccessoryType:UITableViewCellAccessoryCheckmark];
else
[cell setAccessoryType:UITableViewCellAccessoryNone];
break;
case 1:
[cell.textLabel setText:@"Pan Center View"];
if((self.mm_drawerController.openDrawerGestureModeMask&MMOpenDrawerGestureModePanningCenterView)>0)
[cell setAccessoryType:UITableViewCellAccessoryCheckmark];
else
[cell setAccessoryType:UITableViewCellAccessoryNone];
break;
case 2:
[cell.textLabel setText:@"Bezel Pan Center View"];
if((self.mm_drawerController.openDrawerGestureModeMask&MMOpenDrawerGestureModeBezelPanningCenterView)>0)
[cell setAccessoryType:UITableViewCellAccessoryCheckmark];
else
[cell setAccessoryType:UITableViewCellAccessoryNone];
break;
default:
break;
}
break;
}
case MMDrawerSectionCloseDrawerGestures:{
switch (indexPath.row) {
case 0:
[cell.textLabel setText:@"Pan Nav Bar"];
if((self.mm_drawerController.closeDrawerGestureModeMask&MMCloseDrawerGestureModePanningNavigationBar)>0)
[cell setAccessoryType:UITableViewCellAccessoryCheckmark];
else
[cell setAccessoryType:UITableViewCellAccessoryNone];
break;
case 1:
[cell.textLabel setText:@"Pan Center View"];
if((self.mm_drawerController.closeDrawerGestureModeMask&MMCloseDrawerGestureModePanningCenterView)>0)
[cell setAccessoryType:UITableViewCellAccessoryCheckmark];
else
[cell setAccessoryType:UITableViewCellAccessoryNone];
break;
case 2:
[cell.textLabel setText:@"Bezel Pan Center View"];
if((self.mm_drawerController.closeDrawerGestureModeMask&MMCloseDrawerGestureModeBezelPanningCenterView)>0)
[cell setAccessoryType:UITableViewCellAccessoryCheckmark];
else
[cell setAccessoryType:UITableViewCellAccessoryNone];
break;
case 3:
[cell.textLabel setText:@"Tap Nav Bar"];
if((self.mm_drawerController.closeDrawerGestureModeMask&MMCloseDrawerGestureModeTapNavigationBar)>0)
[cell setAccessoryType:UITableViewCellAccessoryCheckmark];
else
[cell setAccessoryType:UITableViewCellAccessoryNone];
break;
case 4:
[cell.textLabel setText:@"Tap Center View"];
if((self.mm_drawerController.closeDrawerGestureModeMask&MMCloseDrawerGestureModeTapCenterView)>0)
[cell setAccessoryType:UITableViewCellAccessoryCheckmark];
else
[cell setAccessoryType:UITableViewCellAccessoryNone];
break;
case 5:
[cell.textLabel setText:@"Pan Drawer View"];
if((self.mm_drawerController.closeDrawerGestureModeMask&MMCloseDrawerGestureModePanningDrawerView)>0)
[cell setAccessoryType:UITableViewCellAccessoryCheckmark];
else
[cell setAccessoryType:UITableViewCellAccessoryNone];
break;
default:
break;
}
break;
}
case MMDrawerSectionCenterHiddenInteraction:{
[cell setSelectionStyle:UITableViewCellSelectionStyleBlue];
switch (indexPath.row) {
case 0:
[cell.textLabel setText:@"None"];
if(self.mm_drawerController.centerHiddenInteractionMode == MMDrawerOpenCenterInteractionModeNone)
[cell setAccessoryType:UITableViewCellAccessoryCheckmark];
else
[cell setAccessoryType:UITableViewCellAccessoryNone];
break;
case 1:
[cell.textLabel setText:@"Full"];
if(self.mm_drawerController.centerHiddenInteractionMode == MMDrawerOpenCenterInteractionModeFull)
[cell setAccessoryType:UITableViewCellAccessoryCheckmark];
else
[cell setAccessoryType:UITableViewCellAccessoryNone];
break;
case 2:
[cell.textLabel setText:@"Nav Bar Only"];
if(self.mm_drawerController.centerHiddenInteractionMode == MMDrawerOpenCenterInteractionModeNavigationBarOnly)
[cell setAccessoryType:UITableViewCellAccessoryCheckmark];
else
[cell setAccessoryType:UITableViewCellAccessoryNone];
break;
default:
break;
}
break;
}
case MMDrawerSectionStretchDrawer:{
[cell.textLabel setText:@"Stretch Drawer"];
if(self.mm_drawerController.shouldStretchDrawer)
[cell setAccessoryType:UITableViewCellAccessoryCheckmark];
else
[cell setAccessoryType:UITableViewCellAccessoryNone];
break;
}
default:
break;
}
return cell;
}
-(NSString*)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section{
switch (section) {
case MMDrawerSectionViewSelection:
return @"New Center View";
case MMDrawerSectionDrawerWidth:
return @"Drawer Width";
case MMDrawerSectionShadowToggle:
return @"Shadow";
case MMDrawerSectionOpenDrawerGestures:
return @"Drawer Open Gestures";
case MMDrawerSectionCloseDrawerGestures:
return @"Drawer Close Gestures";
case MMDrawerSectionCenterHiddenInteraction:
return @"Open Center Interaction Mode";
case MMDrawerSectionStretchDrawer:
return @"Strech Drawer";
default:
return nil;
}
}
-(UIView*)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
MMSideDrawerSectionHeaderView * headerView;
headerView = [[MMSideDrawerSectionHeaderView alloc] initWithFrame:CGRectMake(0, 0, CGRectGetWidth(tableView.bounds), 56.0)];
[headerView setAutoresizingMask:UIViewAutoresizingFlexibleHeight|UIViewAutoresizingFlexibleWidth];
[headerView setTitle:[tableView.dataSource tableView:tableView titleForHeaderInSection:section]];
return headerView;
}
-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
return 56.0;
}
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
return 40.0;
}
-(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
return 0.0;
}
#pragma mark - Table view delegate
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
switch (indexPath.section) {
case MMDrawerSectionViewSelection:{
MMExampleCenterTableViewController * center = [[MMExampleCenterTableViewController alloc] init];
UINavigationController * nav = [[MMNavigationController alloc] initWithRootViewController:center];
if(indexPath.row%2==0){
[self.mm_drawerController
setCenterViewController:nav
withCloseAnimation:YES
completion:nil];
}
else {
[self.mm_drawerController
setCenterViewController:nav
withFullCloseAnimation:YES
completion:nil];
}
break;
}
case MMDrawerSectionDrawerWidth:{
//Implement in Subclass
break;
}
case MMDrawerSectionShadowToggle:{
[self.mm_drawerController setShowsShadow:!self.mm_drawerController.showsShadow];
[tableView reloadSections:[NSIndexSet indexSetWithIndex:indexPath.section] withRowAnimation:UITableViewRowAnimationNone];
break;
}
case MMDrawerSectionOpenDrawerGestures:{
switch (indexPath.row) {
case 0:
self.mm_drawerController.openDrawerGestureModeMask ^= MMOpenDrawerGestureModePanningNavigationBar;
break;
case 1:
self.mm_drawerController.openDrawerGestureModeMask ^= MMOpenDrawerGestureModePanningCenterView;
break;
case 2:
self.mm_drawerController.openDrawerGestureModeMask ^= MMOpenDrawerGestureModeBezelPanningCenterView;
break;
default:
break;
}
[tableView reloadRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationNone];
break;
}
case MMDrawerSectionCloseDrawerGestures:{
switch (indexPath.row) {
case 0:
self.mm_drawerController.closeDrawerGestureModeMask ^= MMCloseDrawerGestureModePanningNavigationBar;
break;
case 1:
self.mm_drawerController.closeDrawerGestureModeMask ^= MMCloseDrawerGestureModePanningCenterView;
break;
case 2:
self.mm_drawerController.closeDrawerGestureModeMask ^= MMCloseDrawerGestureModeBezelPanningCenterView;
break;
case 3:
self.mm_drawerController.closeDrawerGestureModeMask ^= MMCloseDrawerGestureModeTapNavigationBar;
break;
case 4:
self.mm_drawerController.closeDrawerGestureModeMask ^= MMCloseDrawerGestureModeTapCenterView;
break;
case 5:
self.mm_drawerController.closeDrawerGestureModeMask ^= MMCloseDrawerGestureModePanningDrawerView;
break;
default:
break;
}
[tableView reloadRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationNone];
break;
}
case MMDrawerSectionCenterHiddenInteraction:{
self.mm_drawerController.centerHiddenInteractionMode = indexPath.row;
[tableView reloadSections:[NSIndexSet indexSetWithIndex:indexPath.section] withRowAnimation:UITableViewRowAnimationNone];
break;
}
case MMDrawerSectionStretchDrawer:{
self.mm_drawerController.shouldStretchDrawer = !self.mm_drawerController.shouldStretchDrawer;
[tableView reloadRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationNone];
break;
}
default:
break;
}
[tableView selectRowAtIndexPath:indexPath animated:NO scrollPosition:UITableViewScrollPositionNone];
[tableView deselectRowAtIndexPath:indexPath animated:YES];
}
@end
================================================
FILE: KitchenSink/ExampleFiles/MMExampleViewController.h
================================================
// Copyright (c) 2013 Mutual Mobile (http://mutualmobile.com/)
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
#import
@interface MMExampleViewController : UIViewController
-(void)contentSizeDidChange:(NSString*)size;
@end
================================================
FILE: KitchenSink/ExampleFiles/MMExampleViewController.m
================================================
// Copyright (c) 2013 Mutual Mobile (http://mutualmobile.com/)
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
#import "MMExampleViewController.h"
@interface MMExampleViewController ()
@end
@implementation MMExampleViewController
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}
- (void)viewDidLoad
{
[super viewDidLoad];
[[NSNotificationCenter defaultCenter]
addObserver:self
selector:@selector(contentSizeDidChangeNotification:)
name:UIContentSizeCategoryDidChangeNotification
object:nil];
}
- (void)dealloc{
[[NSNotificationCenter defaultCenter]
removeObserver:self];
}
-(void)contentSizeDidChangeNotification:(NSNotification*)notification{
[self contentSizeDidChange:notification.userInfo[UIContentSizeCategoryNewValueKey]];
}
-(void)contentSizeDidChange:(NSString *)size{
//Implement in subclass
}
@end
================================================
FILE: KitchenSink/ExampleFiles/MMLogoView.h
================================================
// Copyright (c) 2013 Mutual Mobile (http://mutualmobile.com/)
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
#import
@interface MMLogoView : UIView
@end
================================================
FILE: KitchenSink/ExampleFiles/MMLogoView.m
================================================
// Copyright (c) 2013 Mutual Mobile (http://mutualmobile.com/)
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
#import "MMLogoView.h"
@implementation MMLogoView
-(id)initWithFrame:(CGRect)frame{
self = [super initWithFrame:frame];
if(self) {
[self setBackgroundColor:[UIColor clearColor]];
}
return self;
}
-(void)drawRect:(CGRect)rect{
//// General Declarations
CGContextRef context = UIGraphicsGetCurrentContext();
//// Color Declarations
UIColor* mmFill = [UIColor colorWithRed: 0 green: 0 blue: 0 alpha: 0.196];
UIColor* shape1DropShadowColor = [UIColor colorWithRed: 1 green: 1 blue: 1 alpha: 0.4];
UIColor* shape1InnerShadowColor = [UIColor colorWithRed: 0 green: 0 blue: 0 alpha: 0.392];
//// Shadow Declarations
UIColor* mmDropShadow = shape1DropShadowColor;
CGSize mmDropShadowOffset = CGSizeMake(0.1, 1.1);
CGFloat mmDropShadowBlurRadius = 0;
UIColor* mmInnerShadow = shape1InnerShadowColor;
CGSize mmInnerShadowOffset = CGSizeMake(0.1, 1.1);
CGFloat mmInnerShadowBlurRadius = 0;
//// Frames
CGRect frame = self.bounds;
//// mmGroup
{
//// mmShape Drawing
UIBezierPath* mmShapePath = [UIBezierPath bezierPath];
[mmShapePath moveToPoint: CGPointMake(CGRectGetMinX(frame) + 0.51759 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.96761 * CGRectGetHeight(frame))];
[mmShapePath addCurveToPoint: CGPointMake(CGRectGetMinX(frame) + 0.37558 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.91398 * CGRectGetHeight(frame)) controlPoint1: CGPointMake(CGRectGetMinX(frame) + 0.46395 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.96761 * CGRectGetHeight(frame)) controlPoint2: CGPointMake(CGRectGetMinX(frame) + 0.41351 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.94854 * CGRectGetHeight(frame))];
[mmShapePath addCurveToPoint: CGPointMake(CGRectGetMinX(frame) + 0.31759 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.76824 * CGRectGetHeight(frame)) controlPoint1: CGPointMake(CGRectGetMinX(frame) + 0.33346 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.87556 * CGRectGetHeight(frame)) controlPoint2: CGPointMake(CGRectGetMinX(frame) + 0.31234 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.82249 * CGRectGetHeight(frame))];
[mmShapePath addLineToPoint: CGPointMake(CGRectGetMinX(frame) + 0.31904 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.75325 * CGRectGetHeight(frame))];
[mmShapePath addLineToPoint: CGPointMake(CGRectGetMinX(frame) + 0.30262 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.75459 * CGRectGetHeight(frame))];
[mmShapePath addCurveToPoint: CGPointMake(CGRectGetMinX(frame) + 0.28470 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.75535 * CGRectGetHeight(frame)) controlPoint1: CGPointMake(CGRectGetMinX(frame) + 0.29666 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.75510 * CGRectGetHeight(frame)) controlPoint2: CGPointMake(CGRectGetMinX(frame) + 0.29065 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.75535 * CGRectGetHeight(frame))];
[mmShapePath addCurveToPoint: CGPointMake(CGRectGetMinX(frame) + 0.14274 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.70173 * CGRectGetHeight(frame)) controlPoint1: CGPointMake(CGRectGetMinX(frame) + 0.23106 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.75535 * CGRectGetHeight(frame)) controlPoint2: CGPointMake(CGRectGetMinX(frame) + 0.18067 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.73625 * CGRectGetHeight(frame))];
[mmShapePath addCurveToPoint: CGPointMake(CGRectGetMinX(frame) + 0.14274 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.44291 * CGRectGetHeight(frame)) controlPoint1: CGPointMake(CGRectGetMinX(frame) + 0.06451 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.63038 * CGRectGetHeight(frame)) controlPoint2: CGPointMake(CGRectGetMinX(frame) + 0.06451 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.51425 * CGRectGetHeight(frame))];
[mmShapePath addLineToPoint: CGPointMake(CGRectGetMinX(frame) + 0.45528 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.15799 * CGRectGetHeight(frame))];
[mmShapePath addCurveToPoint: CGPointMake(CGRectGetMinX(frame) + 0.48085 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.14832 * CGRectGetHeight(frame)) controlPoint1: CGPointMake(CGRectGetMinX(frame) + 0.46207 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.15176 * CGRectGetHeight(frame)) controlPoint2: CGPointMake(CGRectGetMinX(frame) + 0.47120 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.14832 * CGRectGetHeight(frame))];
[mmShapePath addCurveToPoint: CGPointMake(CGRectGetMinX(frame) + 0.50639 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.15799 * CGRectGetHeight(frame)) controlPoint1: CGPointMake(CGRectGetMinX(frame) + 0.49051 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.14832 * CGRectGetHeight(frame)) controlPoint2: CGPointMake(CGRectGetMinX(frame) + 0.49957 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.15176 * CGRectGetHeight(frame))];
[mmShapePath addCurveToPoint: CGPointMake(CGRectGetMinX(frame) + 0.50639 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.20462 * CGRectGetHeight(frame)) controlPoint1: CGPointMake(CGRectGetMinX(frame) + 0.52050 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.17087 * CGRectGetHeight(frame)) controlPoint2: CGPointMake(CGRectGetMinX(frame) + 0.52050 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.19177 * CGRectGetHeight(frame))];
[mmShapePath addLineToPoint: CGPointMake(CGRectGetMinX(frame) + 0.19390 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.48951 * CGRectGetHeight(frame))];
[mmShapePath addCurveToPoint: CGPointMake(CGRectGetMinX(frame) + 0.19386 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.65510 * CGRectGetHeight(frame)) controlPoint1: CGPointMake(CGRectGetMinX(frame) + 0.14397 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.53518 * CGRectGetHeight(frame)) controlPoint2: CGPointMake(CGRectGetMinX(frame) + 0.14397 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.60942 * CGRectGetHeight(frame))];
[mmShapePath addCurveToPoint: CGPointMake(CGRectGetMinX(frame) + 0.28476 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.68936 * CGRectGetHeight(frame)) controlPoint1: CGPointMake(CGRectGetMinX(frame) + 0.21821 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.67720 * CGRectGetHeight(frame)) controlPoint2: CGPointMake(CGRectGetMinX(frame) + 0.25047 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.68936 * CGRectGetHeight(frame))];
[mmShapePath addCurveToPoint: CGPointMake(CGRectGetMinX(frame) + 0.37557 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.65514 * CGRectGetHeight(frame)) controlPoint1: CGPointMake(CGRectGetMinX(frame) + 0.31904 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.68936 * CGRectGetHeight(frame)) controlPoint2: CGPointMake(CGRectGetMinX(frame) + 0.35128 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.67720 * CGRectGetHeight(frame))];
[mmShapePath addLineToPoint: CGPointMake(CGRectGetMinX(frame) + 0.68812 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.37025 * CGRectGetHeight(frame))];
[mmShapePath addCurveToPoint: CGPointMake(CGRectGetMinX(frame) + 0.71365 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.36056 * CGRectGetHeight(frame)) controlPoint1: CGPointMake(CGRectGetMinX(frame) + 0.69491 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.36401 * CGRectGetHeight(frame)) controlPoint2: CGPointMake(CGRectGetMinX(frame) + 0.70403 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.36056 * CGRectGetHeight(frame))];
[mmShapePath addCurveToPoint: CGPointMake(CGRectGetMinX(frame) + 0.73923 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.37025 * CGRectGetHeight(frame)) controlPoint1: CGPointMake(CGRectGetMinX(frame) + 0.72332 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.36056 * CGRectGetHeight(frame)) controlPoint2: CGPointMake(CGRectGetMinX(frame) + 0.73241 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.36401 * CGRectGetHeight(frame))];
[mmShapePath addCurveToPoint: CGPointMake(CGRectGetMinX(frame) + 0.73923 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.41681 * CGRectGetHeight(frame)) controlPoint1: CGPointMake(CGRectGetMinX(frame) + 0.75333 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.38310 * CGRectGetHeight(frame)) controlPoint2: CGPointMake(CGRectGetMinX(frame) + 0.75333 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.40399 * CGRectGetHeight(frame))];
[mmShapePath addLineToPoint: CGPointMake(CGRectGetMinX(frame) + 0.42673 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.70173 * CGRectGetHeight(frame))];
[mmShapePath addCurveToPoint: CGPointMake(CGRectGetMinX(frame) + 0.42670 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.86737 * CGRectGetHeight(frame)) controlPoint1: CGPointMake(CGRectGetMinX(frame) + 0.37681 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.74744 * CGRectGetHeight(frame)) controlPoint2: CGPointMake(CGRectGetMinX(frame) + 0.37681 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.82172 * CGRectGetHeight(frame))];
[mmShapePath addCurveToPoint: CGPointMake(CGRectGetMinX(frame) + 0.51759 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.90159 * CGRectGetHeight(frame)) controlPoint1: CGPointMake(CGRectGetMinX(frame) + 0.45104 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.88944 * CGRectGetHeight(frame)) controlPoint2: CGPointMake(CGRectGetMinX(frame) + 0.48328 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.90159 * CGRectGetHeight(frame))];
[mmShapePath addCurveToPoint: CGPointMake(CGRectGetMinX(frame) + 0.60840 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.86743 * CGRectGetHeight(frame)) controlPoint1: CGPointMake(CGRectGetMinX(frame) + 0.55183 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.90159 * CGRectGetHeight(frame)) controlPoint2: CGPointMake(CGRectGetMinX(frame) + 0.58413 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.88944 * CGRectGetHeight(frame))];
[mmShapePath addLineToPoint: CGPointMake(CGRectGetMinX(frame) + 0.92092 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.58246 * CGRectGetHeight(frame))];
[mmShapePath addCurveToPoint: CGPointMake(CGRectGetMinX(frame) + 0.94646 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.57284 * CGRectGetHeight(frame)) controlPoint1: CGPointMake(CGRectGetMinX(frame) + 0.92773 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.57623 * CGRectGetHeight(frame)) controlPoint2: CGPointMake(CGRectGetMinX(frame) + 0.93682 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.57284 * CGRectGetHeight(frame))];
[mmShapePath addCurveToPoint: CGPointMake(CGRectGetMinX(frame) + 0.97208 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.58246 * CGRectGetHeight(frame)) controlPoint1: CGPointMake(CGRectGetMinX(frame) + 0.95617 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.57284 * CGRectGetHeight(frame)) controlPoint2: CGPointMake(CGRectGetMinX(frame) + 0.96523 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.57623 * CGRectGetHeight(frame))];
[mmShapePath addCurveToPoint: CGPointMake(CGRectGetMinX(frame) + 0.97208 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.62912 * CGRectGetHeight(frame)) controlPoint1: CGPointMake(CGRectGetMinX(frame) + 0.98615 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.59535 * CGRectGetHeight(frame)) controlPoint2: CGPointMake(CGRectGetMinX(frame) + 0.98615 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.61626 * CGRectGetHeight(frame))];
[mmShapePath addLineToPoint: CGPointMake(CGRectGetMinX(frame) + 0.65956 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.91398 * CGRectGetHeight(frame))];
[mmShapePath addCurveToPoint: CGPointMake(CGRectGetMinX(frame) + 0.51759 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.96761 * CGRectGetHeight(frame)) controlPoint1: CGPointMake(CGRectGetMinX(frame) + 0.62160 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.94854 * CGRectGetHeight(frame)) controlPoint2: CGPointMake(CGRectGetMinX(frame) + 0.57117 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.96761 * CGRectGetHeight(frame))];
[mmShapePath addLineToPoint: CGPointMake(CGRectGetMinX(frame) + 0.51759 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.96761 * CGRectGetHeight(frame))];
[mmShapePath closePath];
[mmShapePath moveToPoint: CGPointMake(CGRectGetMinX(frame) + 0.51965 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.81940 * CGRectGetHeight(frame))];
[mmShapePath addCurveToPoint: CGPointMake(CGRectGetMinX(frame) + 0.49408 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.80982 * CGRectGetHeight(frame)) controlPoint1: CGPointMake(CGRectGetMinX(frame) + 0.50999 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.81940 * CGRectGetHeight(frame)) controlPoint2: CGPointMake(CGRectGetMinX(frame) + 0.50091 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.81600 * CGRectGetHeight(frame))];
[mmShapePath addCurveToPoint: CGPointMake(CGRectGetMinX(frame) + 0.49408 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.76313 * CGRectGetHeight(frame)) controlPoint1: CGPointMake(CGRectGetMinX(frame) + 0.48000 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.79686 * CGRectGetHeight(frame)) controlPoint2: CGPointMake(CGRectGetMinX(frame) + 0.48000 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.77600 * CGRectGetHeight(frame))];
[mmShapePath addLineToPoint: CGPointMake(CGRectGetMinX(frame) + 0.80659 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.47824 * CGRectGetHeight(frame))];
[mmShapePath addCurveToPoint: CGPointMake(CGRectGetMinX(frame) + 0.80662 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.31264 * CGRectGetHeight(frame)) controlPoint1: CGPointMake(CGRectGetMinX(frame) + 0.85650 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.43259 * CGRectGetHeight(frame)) controlPoint2: CGPointMake(CGRectGetMinX(frame) + 0.85650 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.35831 * CGRectGetHeight(frame))];
[mmShapePath addCurveToPoint: CGPointMake(CGRectGetMinX(frame) + 0.71574 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.27840 * CGRectGetHeight(frame)) controlPoint1: CGPointMake(CGRectGetMinX(frame) + 0.78226 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.29053 * CGRectGetHeight(frame)) controlPoint2: CGPointMake(CGRectGetMinX(frame) + 0.75001 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.27840 * CGRectGetHeight(frame))];
[mmShapePath addCurveToPoint: CGPointMake(CGRectGetMinX(frame) + 0.62493 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.31260 * CGRectGetHeight(frame)) controlPoint1: CGPointMake(CGRectGetMinX(frame) + 0.68146 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.27840 * CGRectGetHeight(frame)) controlPoint2: CGPointMake(CGRectGetMinX(frame) + 0.64921 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.29053 * CGRectGetHeight(frame))];
[mmShapePath addLineToPoint: CGPointMake(CGRectGetMinX(frame) + 0.31239 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.59752 * CGRectGetHeight(frame))];
[mmShapePath addCurveToPoint: CGPointMake(CGRectGetMinX(frame) + 0.28684 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.60718 * CGRectGetHeight(frame)) controlPoint1: CGPointMake(CGRectGetMinX(frame) + 0.30556 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.60378 * CGRectGetHeight(frame)) controlPoint2: CGPointMake(CGRectGetMinX(frame) + 0.29644 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.60718 * CGRectGetHeight(frame))];
[mmShapePath addCurveToPoint: CGPointMake(CGRectGetMinX(frame) + 0.26125 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.59752 * CGRectGetHeight(frame)) controlPoint1: CGPointMake(CGRectGetMinX(frame) + 0.27718 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.60718 * CGRectGetHeight(frame)) controlPoint2: CGPointMake(CGRectGetMinX(frame) + 0.26808 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.60378 * CGRectGetHeight(frame))];
[mmShapePath addCurveToPoint: CGPointMake(CGRectGetMinX(frame) + 0.26125 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.55093 * CGRectGetHeight(frame)) controlPoint1: CGPointMake(CGRectGetMinX(frame) + 0.24715 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.58467 * CGRectGetHeight(frame)) controlPoint2: CGPointMake(CGRectGetMinX(frame) + 0.24715 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.56377 * CGRectGetHeight(frame))];
[mmShapePath addLineToPoint: CGPointMake(CGRectGetMinX(frame) + 0.57377 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.26601 * CGRectGetHeight(frame))];
[mmShapePath addCurveToPoint: CGPointMake(CGRectGetMinX(frame) + 0.57380 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.10041 * CGRectGetHeight(frame)) controlPoint1: CGPointMake(CGRectGetMinX(frame) + 0.62368 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.22029 * CGRectGetHeight(frame)) controlPoint2: CGPointMake(CGRectGetMinX(frame) + 0.62368 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.14606 * CGRectGetHeight(frame))];
[mmShapePath addCurveToPoint: CGPointMake(CGRectGetMinX(frame) + 0.48291 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.06617 * CGRectGetHeight(frame)) controlPoint1: CGPointMake(CGRectGetMinX(frame) + 0.54946 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.07832 * CGRectGetHeight(frame)) controlPoint2: CGPointMake(CGRectGetMinX(frame) + 0.51721 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.06617 * CGRectGetHeight(frame))];
[mmShapePath addCurveToPoint: CGPointMake(CGRectGetMinX(frame) + 0.39208 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.10040 * CGRectGetHeight(frame)) controlPoint1: CGPointMake(CGRectGetMinX(frame) + 0.44863 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.06617 * CGRectGetHeight(frame)) controlPoint2: CGPointMake(CGRectGetMinX(frame) + 0.41637 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.07832 * CGRectGetHeight(frame))];
[mmShapePath addLineToPoint: CGPointMake(CGRectGetMinX(frame) + 0.07956 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.38530 * CGRectGetHeight(frame))];
[mmShapePath addCurveToPoint: CGPointMake(CGRectGetMinX(frame) + 0.05400 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.39496 * CGRectGetHeight(frame)) controlPoint1: CGPointMake(CGRectGetMinX(frame) + 0.07274 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.39149 * CGRectGetHeight(frame)) controlPoint2: CGPointMake(CGRectGetMinX(frame) + 0.06365 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.39496 * CGRectGetHeight(frame))];
[mmShapePath addCurveToPoint: CGPointMake(CGRectGetMinX(frame) + 0.02841 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.38530 * CGRectGetHeight(frame)) controlPoint1: CGPointMake(CGRectGetMinX(frame) + 0.04434 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.39496 * CGRectGetHeight(frame)) controlPoint2: CGPointMake(CGRectGetMinX(frame) + 0.03525 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.39149 * CGRectGetHeight(frame))];
[mmShapePath addCurveToPoint: CGPointMake(CGRectGetMinX(frame) + 0.02841 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.33867 * CGRectGetHeight(frame)) controlPoint1: CGPointMake(CGRectGetMinX(frame) + 0.01434 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.37241 * CGRectGetHeight(frame)) controlPoint2: CGPointMake(CGRectGetMinX(frame) + 0.01434 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.35151 * CGRectGetHeight(frame))];
[mmShapePath addLineToPoint: CGPointMake(CGRectGetMinX(frame) + 0.34095 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.05378 * CGRectGetHeight(frame))];
[mmShapePath addCurveToPoint: CGPointMake(CGRectGetMinX(frame) + 0.48291 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.00013 * CGRectGetHeight(frame)) controlPoint1: CGPointMake(CGRectGetMinX(frame) + 0.37888 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.01919 * CGRectGetHeight(frame)) controlPoint2: CGPointMake(CGRectGetMinX(frame) + 0.42931 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.00013 * CGRectGetHeight(frame))];
[mmShapePath addCurveToPoint: CGPointMake(CGRectGetMinX(frame) + 0.62491 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.05378 * CGRectGetHeight(frame)) controlPoint1: CGPointMake(CGRectGetMinX(frame) + 0.53657 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.00013 * CGRectGetHeight(frame)) controlPoint2: CGPointMake(CGRectGetMinX(frame) + 0.58700 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.01919 * CGRectGetHeight(frame))];
[mmShapePath addCurveToPoint: CGPointMake(CGRectGetMinX(frame) + 0.68292 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.19950 * CGRectGetHeight(frame)) controlPoint1: CGPointMake(CGRectGetMinX(frame) + 0.66705 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.09219 * CGRectGetHeight(frame)) controlPoint2: CGPointMake(CGRectGetMinX(frame) + 0.68815 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.14529 * CGRectGetHeight(frame))];
[mmShapePath addLineToPoint: CGPointMake(CGRectGetMinX(frame) + 0.68143 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.21454 * CGRectGetHeight(frame))];
[mmShapePath addLineToPoint: CGPointMake(CGRectGetMinX(frame) + 0.69786 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.21318 * CGRectGetHeight(frame))];
[mmShapePath addCurveToPoint: CGPointMake(CGRectGetMinX(frame) + 0.71580 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.21244 * CGRectGetHeight(frame)) controlPoint1: CGPointMake(CGRectGetMinX(frame) + 0.70379 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.21269 * CGRectGetHeight(frame)) controlPoint2: CGPointMake(CGRectGetMinX(frame) + 0.70984 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.21244 * CGRectGetHeight(frame))];
[mmShapePath addCurveToPoint: CGPointMake(CGRectGetMinX(frame) + 0.85774 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.26604 * CGRectGetHeight(frame)) controlPoint1: CGPointMake(CGRectGetMinX(frame) + 0.76941 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.21244 * CGRectGetHeight(frame)) controlPoint2: CGPointMake(CGRectGetMinX(frame) + 0.81981 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.23147 * CGRectGetHeight(frame))];
[mmShapePath addCurveToPoint: CGPointMake(CGRectGetMinX(frame) + 0.85774 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.52485 * CGRectGetHeight(frame)) controlPoint1: CGPointMake(CGRectGetMinX(frame) + 0.93599 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.33738 * CGRectGetHeight(frame)) controlPoint2: CGPointMake(CGRectGetMinX(frame) + 0.93599 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.45349 * CGRectGetHeight(frame))];
[mmShapePath addLineToPoint: CGPointMake(CGRectGetMinX(frame) + 0.54521 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.80977 * CGRectGetHeight(frame))];
[mmShapePath addCurveToPoint: CGPointMake(CGRectGetMinX(frame) + 0.51965 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.81940 * CGRectGetHeight(frame)) controlPoint1: CGPointMake(CGRectGetMinX(frame) + 0.53840 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.81600 * CGRectGetHeight(frame)) controlPoint2: CGPointMake(CGRectGetMinX(frame) + 0.52930 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.81940 * CGRectGetHeight(frame))];
[mmShapePath addLineToPoint: CGPointMake(CGRectGetMinX(frame) + 0.51965 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.81940 * CGRectGetHeight(frame))];
[mmShapePath closePath];
CGContextSaveGState(context);
CGContextSetShadowWithColor(context, mmDropShadowOffset, mmDropShadowBlurRadius, mmDropShadow.CGColor);
CGContextSetBlendMode(context, kCGBlendModeOverlay);
[mmFill setFill];
[mmShapePath fill];
////// mmShape Inner Shadow
CGRect mmShapeBorderRect = CGRectInset([mmShapePath bounds], -mmInnerShadowBlurRadius, -mmInnerShadowBlurRadius);
mmShapeBorderRect = CGRectOffset(mmShapeBorderRect, -mmInnerShadowOffset.width, -mmInnerShadowOffset.height);
mmShapeBorderRect = CGRectInset(CGRectUnion(mmShapeBorderRect, [mmShapePath bounds]), -1, -1);
UIBezierPath* mmShapeNegativePath = [UIBezierPath bezierPathWithRect: mmShapeBorderRect];
[mmShapeNegativePath appendPath: mmShapePath];
mmShapeNegativePath.usesEvenOddFillRule = YES;
CGContextSaveGState(context);
{
CGFloat xOffset = mmInnerShadowOffset.width + round(mmShapeBorderRect.size.width);
CGFloat yOffset = mmInnerShadowOffset.height;
CGContextSetShadowWithColor(context,
CGSizeMake(xOffset + copysign(0.1, xOffset), yOffset + copysign(0.1, yOffset)),
mmInnerShadowBlurRadius,
mmInnerShadow.CGColor);
[mmShapePath addClip];
CGAffineTransform transform = CGAffineTransformMakeTranslation(-round(mmShapeBorderRect.size.width), 0);
[mmShapeNegativePath applyTransform: transform];
[[UIColor grayColor] setFill];
[mmShapeNegativePath fill];
}
CGContextRestoreGState(context);
CGContextRestoreGState(context);
}
}
@end
================================================
FILE: KitchenSink/ExampleFiles/MMNavigationController.h
================================================
// Copyright (c) 2013 Mutual Mobile (http://mutualmobile.com/)
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
#import
@interface MMNavigationController : UINavigationController
@end
================================================
FILE: KitchenSink/ExampleFiles/MMNavigationController.m
================================================
// Copyright (c) 2013 Mutual Mobile (http://mutualmobile.com/)
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
#import "MMNavigationController.h"
#import "UIViewController+MMDrawerController.h"
@interface MMNavigationController ()
@end
@implementation MMNavigationController
-(UIStatusBarStyle)preferredStatusBarStyle{
if(self.mm_drawerController.showsStatusBarBackgroundView){
return UIStatusBarStyleLightContent;
}
else {
return UIStatusBarStyleDefault;
}
}
@end
================================================
FILE: KitchenSink/ExampleFiles/MMSideDrawerSectionHeaderView.h
================================================
// Copyright (c) 2013 Mutual Mobile (http://mutualmobile.com/)
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
#import
@interface MMSideDrawerSectionHeaderView : UIView
@property (nonatomic, copy) NSString * title;
@end
================================================
FILE: KitchenSink/ExampleFiles/MMSideDrawerSectionHeaderView.m
================================================
// Copyright (c) 2013 Mutual Mobile (http://mutualmobile.com/)
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
#import "MMSideDrawerSectionHeaderView.h"
#import
@interface MMSideDrawerSectionHeaderView ()
@property (nonatomic, strong) UILabel * label;
@end
@implementation MMSideDrawerSectionHeaderView
- (id)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self) {
// Initialization code
[self setBackgroundColor:[UIColor colorWithRed:110./255.0
green:113.0/255.0
blue:115.0/255.0
alpha:1.0]];
_label = [[UILabel alloc] initWithFrame:CGRectMake(15, CGRectGetMaxY(self.bounds)-28,CGRectGetWidth(self.bounds)-30, 22)];
if([[UIFont class] respondsToSelector:@selector(preferredFontForTextStyle:)]){
[self.label setFont:[UIFont preferredFontForTextStyle:UIFontTextStyleCaption1]];
}
else {
[self.label setFont:[UIFont boldSystemFontOfSize:12.0]];
}
[self.label setBackgroundColor:[UIColor clearColor]];
[self.label setTextColor:[UIColor colorWithRed:203.0/255.0
green:206.0/255.0
blue:209.0/255.0
alpha:1.0]];
[self.label setAutoresizingMask:UIViewAutoresizingFlexibleWidth|UIViewAutoresizingFlexibleTopMargin];
[self addSubview:self.label];
[self setClipsToBounds:NO];
}
return self;
}
-(void)setTitle:(NSString *)title{
_title = title;
[self.label setText:[self.title uppercaseString]];
}
-(void)drawRect:(CGRect)rect{
//// General Declarations
CGContextRef context = UIGraphicsGetCurrentContext();
UIColor * lineColor = [UIColor colorWithRed:94.0/255.0
green:97.0/255.0
blue:99.0/255.0
alpha:1.0];
CGContextSetStrokeColorWithColor(context, lineColor.CGColor);
CGContextSetLineWidth(context, 1.0);
CGContextMoveToPoint(context, CGRectGetMinX(self.bounds), CGRectGetMaxY(self.bounds)-.5); //start at this point
CGContextAddLineToPoint(context, CGRectGetMaxX(self.bounds), CGRectGetMaxY(self.bounds)-.5); //draw to this point
CGContextStrokePath(context);
}
@end
================================================
FILE: KitchenSink/ExampleFiles/MMSideDrawerTableViewCell.h
================================================
// Copyright (c) 2013 Mutual Mobile (http://mutualmobile.com/)
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
#import "MMTableViewCell.h"
@interface MMSideDrawerTableViewCell : MMTableViewCell
@end
================================================
FILE: KitchenSink/ExampleFiles/MMSideDrawerTableViewCell.m
================================================
// Copyright (c) 2013 Mutual Mobile (http://mutualmobile.com/)
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
#import "MMSideDrawerTableViewCell.h"
@implementation MMSideDrawerTableViewCell
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
if (self) {
[self setAccessoryCheckmarkColor:[UIColor whiteColor]];
UIView * backgroundView = [[UIView alloc] initWithFrame:self.bounds];
[backgroundView setAutoresizingMask:UIViewAutoresizingFlexibleHeight|UIViewAutoresizingFlexibleWidth];
UIColor * backgroundColor;
backgroundColor = [UIColor colorWithRed:122.0/255.0
green:126.0/255.0
blue:128.0/255.0
alpha:1.0];
[backgroundView setBackgroundColor:backgroundColor];
[self setBackgroundView:backgroundView];
[self.textLabel setBackgroundColor:[UIColor clearColor]];
[self.textLabel setTextColor:[UIColor
colorWithRed:230.0/255.0
green:236.0/255.0
blue:242.0/255.0
alpha:1.0]];
}
return self;
}
-(void)updateContentForNewContentSize{
if([[UIFont class] respondsToSelector:@selector(preferredFontForTextStyle:)]){
[self.textLabel setFont:[UIFont preferredFontForTextStyle:UIFontTextStyleBody]];
}
else {
[self.textLabel setFont:[UIFont boldSystemFontOfSize:16.0]];
}
}
@end
================================================
FILE: KitchenSink/ExampleFiles/MMTableViewCell.h
================================================
// Copyright (c) 2013 Mutual Mobile (http://mutualmobile.com/)
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
#import
@interface MMTableViewCell : UITableViewCell
@property (nonatomic, strong) UIColor * accessoryCheckmarkColor;
@property (nonatomic, strong) UIColor * disclosureIndicatorColor;
-(void)updateContentForNewContentSize;
@end
================================================
FILE: KitchenSink/ExampleFiles/MMTableViewCell.m
================================================
// Copyright (c) 2013 Mutual Mobile (http://mutualmobile.com/)
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
#import "MMTableViewCell.h"
@interface MMDisclosureIndicator : UIView
@property (nonatomic, strong) UIColor * color;
@end
@implementation MMDisclosureIndicator
-(id)initWithFrame:(CGRect)frame{
self = [super initWithFrame:frame];
if(self){
[self setBackgroundColor:[UIColor clearColor]];
[self setColor:[UIColor whiteColor]];
}
return self;
}
-(void)drawRect:(CGRect)rect{
//// General Declarations
CGContextRef context = UIGraphicsGetCurrentContext();
//// Color Declarations
UIColor* shadow;
shadow = [UIColor clearColor];
UIColor* chevronColor = self.color;
//// Shadow Declarations
CGSize shadowOffset = CGSizeMake(0.1, 1.1);
CGFloat shadowBlurRadius = 0;
//// Frames
CGRect frame = self.bounds;
//// chevron Drawing
UIBezierPath* chevronPath = [UIBezierPath bezierPath];
[chevronPath moveToPoint: CGPointMake(CGRectGetMinX(frame) + 0.22000 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.01667 * CGRectGetHeight(frame))];
[chevronPath addLineToPoint: CGPointMake(CGRectGetMinX(frame) + 0.98000 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.48333 * CGRectGetHeight(frame))];
[chevronPath addLineToPoint: CGPointMake(CGRectGetMinX(frame) + 0.22000 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.98333 * CGRectGetHeight(frame))];
[chevronPath addLineToPoint: CGPointMake(CGRectGetMinX(frame) + 0.02000 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.81667 * CGRectGetHeight(frame))];
[chevronPath addLineToPoint: CGPointMake(CGRectGetMinX(frame) + 0.54000 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.48333 * CGRectGetHeight(frame))];
[chevronPath addLineToPoint: CGPointMake(CGRectGetMinX(frame) + 0.02000 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.15000 * CGRectGetHeight(frame))];
[chevronPath addLineToPoint: CGPointMake(CGRectGetMinX(frame) + 0.22000 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.01667 * CGRectGetHeight(frame))];
[chevronPath closePath];
CGContextSaveGState(context);
CGContextSetShadowWithColor(context, shadowOffset, shadowBlurRadius, shadow.CGColor);
[chevronColor setFill];
[chevronPath fill];
CGContextRestoreGState(context);
}
@end
@interface MMCustomCheckmark : UIControl
@property (nonatomic, strong) UIColor * color;
@end
@implementation MMCustomCheckmark
-(id)initWithFrame:(CGRect)frame{
self = [super initWithFrame:frame];
if(self) {
[self setBackgroundColor:[UIColor clearColor]];
[self setUserInteractionEnabled:NO];
}
return self;
}
-(void)drawRect:(CGRect)rect{
//// Color Declarations
UIColor* checkMarkColor = self.color;
//// Frames
CGRect frame = self.bounds;
//// checkMark Drawing
UIBezierPath* checkMarkPath = [UIBezierPath bezierPath];
[checkMarkPath moveToPoint: CGPointMake(CGRectGetMinX(frame) + 0.07087 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.48855 * CGRectGetHeight(frame))];
[checkMarkPath addLineToPoint: CGPointMake(CGRectGetMinX(frame) + 0.12500 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.45284 * CGRectGetHeight(frame))];
[checkMarkPath addCurveToPoint: CGPointMake(CGRectGetMinX(frame) + 0.21038 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.47898 * CGRectGetHeight(frame)) controlPoint1: CGPointMake(CGRectGetMinX(frame) + 0.15489 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.43312 * CGRectGetHeight(frame)) controlPoint2: CGPointMake(CGRectGetMinX(frame) + 0.19312 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.44482 * CGRectGetHeight(frame))];
[checkMarkPath addLineToPoint: CGPointMake(CGRectGetMinX(frame) + 0.51450 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.79528 * CGRectGetHeight(frame))];
[checkMarkPath addCurveToPoint: CGPointMake(CGRectGetMinX(frame) + 0.49163 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.89286 * CGRectGetHeight(frame)) controlPoint1: CGPointMake(CGRectGetMinX(frame) + 0.53176 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.82945 * CGRectGetHeight(frame)) controlPoint2: CGPointMake(CGRectGetMinX(frame) + 0.52152 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.87313 * CGRectGetHeight(frame))];
[checkMarkPath addLineToPoint: CGPointMake(CGRectGetMinX(frame) + 0.38337 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.96429 * CGRectGetHeight(frame))];
[checkMarkPath addCurveToPoint: CGPointMake(CGRectGetMinX(frame) + 0.29800 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.93814 * CGRectGetHeight(frame)) controlPoint1: CGPointMake(CGRectGetMinX(frame) + 0.35348 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.98401 * CGRectGetHeight(frame)) controlPoint2: CGPointMake(CGRectGetMinX(frame) + 0.31526 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.97230 * CGRectGetHeight(frame))];
[checkMarkPath addLineToPoint: CGPointMake(CGRectGetMinX(frame) + 0.04800 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.58613 * CGRectGetHeight(frame))];
[checkMarkPath addCurveToPoint: CGPointMake(CGRectGetMinX(frame) + 0.07087 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.48855 * CGRectGetHeight(frame)) controlPoint1: CGPointMake(CGRectGetMinX(frame) + 0.03074 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.55196 * CGRectGetHeight(frame)) controlPoint2: CGPointMake(CGRectGetMinX(frame) + 0.04098 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.50828 * CGRectGetHeight(frame))];
[checkMarkPath closePath];
[checkMarkPath moveToPoint: CGPointMake(CGRectGetMinX(frame) + 0.92048 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.00641 * CGRectGetHeight(frame))];
[checkMarkPath addLineToPoint: CGPointMake(CGRectGetMinX(frame) + 0.93750 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.02427 * CGRectGetHeight(frame))];
[checkMarkPath addCurveToPoint: CGPointMake(CGRectGetMinX(frame) + 0.96038 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.12184 * CGRectGetHeight(frame)) controlPoint1: CGPointMake(CGRectGetMinX(frame) + 0.96739 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.04399 * CGRectGetHeight(frame)) controlPoint2: CGPointMake(CGRectGetMinX(frame) + 0.97764 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.08768 * CGRectGetHeight(frame))];
[checkMarkPath addLineToPoint: CGPointMake(CGRectGetMinX(frame) + 0.51450 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.93814 * CGRectGetHeight(frame))];
[checkMarkPath addCurveToPoint: CGPointMake(CGRectGetMinX(frame) + 0.42913 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.96429 * CGRectGetHeight(frame)) controlPoint1: CGPointMake(CGRectGetMinX(frame) + 0.49724 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.97230 * CGRectGetHeight(frame)) controlPoint2: CGPointMake(CGRectGetMinX(frame) + 0.45902 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.98401 * CGRectGetHeight(frame))];
[checkMarkPath addLineToPoint: CGPointMake(CGRectGetMinX(frame) + 0.32087 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.89286 * CGRectGetHeight(frame))];
[checkMarkPath addCurveToPoint: CGPointMake(CGRectGetMinX(frame) + 0.29800 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.79528 * CGRectGetHeight(frame)) controlPoint1: CGPointMake(CGRectGetMinX(frame) + 0.29098 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.87313 * CGRectGetHeight(frame)) controlPoint2: CGPointMake(CGRectGetMinX(frame) + 0.28074 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.82945 * CGRectGetHeight(frame))];
[checkMarkPath addLineToPoint: CGPointMake(CGRectGetMinX(frame) + 0.83511 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.03255 * CGRectGetHeight(frame))];
[checkMarkPath addCurveToPoint: CGPointMake(CGRectGetMinX(frame) + 0.92048 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.00641 * CGRectGetHeight(frame)) controlPoint1: CGPointMake(CGRectGetMinX(frame) + 0.85237 * CGRectGetWidth(frame), CGRectGetMinY(frame) + -0.00161 * CGRectGetHeight(frame)) controlPoint2: CGPointMake(CGRectGetMinX(frame) + 0.89059 * CGRectGetWidth(frame), CGRectGetMinY(frame) + -0.01331 * CGRectGetHeight(frame))];
[checkMarkPath closePath];
[checkMarkPath moveToPoint: CGPointMake(CGRectGetMinX(frame) + 0.37500 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.78572 * CGRectGetHeight(frame))];
[checkMarkPath addLineToPoint: CGPointMake(CGRectGetMinX(frame) + 0.43750 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.78572 * CGRectGetHeight(frame))];
[checkMarkPath addCurveToPoint: CGPointMake(CGRectGetMinX(frame) + 0.50000 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.85714 * CGRectGetHeight(frame)) controlPoint1: CGPointMake(CGRectGetMinX(frame) + 0.47202 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.78572 * CGRectGetHeight(frame)) controlPoint2: CGPointMake(CGRectGetMinX(frame) + 0.50000 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.81769 * CGRectGetHeight(frame))];
[checkMarkPath addLineToPoint: CGPointMake(CGRectGetMinX(frame) + 0.50000 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.92857 * CGRectGetHeight(frame))];
[checkMarkPath addCurveToPoint: CGPointMake(CGRectGetMinX(frame) + 0.43750 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 1.00000 * CGRectGetHeight(frame)) controlPoint1: CGPointMake(CGRectGetMinX(frame) + 0.50000 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.96802 * CGRectGetHeight(frame)) controlPoint2: CGPointMake(CGRectGetMinX(frame) + 0.47202 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 1.00000 * CGRectGetHeight(frame))];
[checkMarkPath addLineToPoint: CGPointMake(CGRectGetMinX(frame) + 0.37500 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 1.00000 * CGRectGetHeight(frame))];
[checkMarkPath addCurveToPoint: CGPointMake(CGRectGetMinX(frame) + 0.31250 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.92857 * CGRectGetHeight(frame)) controlPoint1: CGPointMake(CGRectGetMinX(frame) + 0.34048 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 1.00000 * CGRectGetHeight(frame)) controlPoint2: CGPointMake(CGRectGetMinX(frame) + 0.31250 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.96802 * CGRectGetHeight(frame))];
[checkMarkPath addLineToPoint: CGPointMake(CGRectGetMinX(frame) + 0.31250 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.85714 * CGRectGetHeight(frame))];
[checkMarkPath addCurveToPoint: CGPointMake(CGRectGetMinX(frame) + 0.37500 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.78572 * CGRectGetHeight(frame)) controlPoint1: CGPointMake(CGRectGetMinX(frame) + 0.31250 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.81769 * CGRectGetHeight(frame)) controlPoint2: CGPointMake(CGRectGetMinX(frame) + 0.34048 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.78572 * CGRectGetHeight(frame))];
[checkMarkPath closePath];
[checkMarkColor setFill];
[checkMarkPath fill];
}
-(void)setSelected:(BOOL)selected{
[super setSelected:selected];
[self setNeedsDisplay];
}
@end
@implementation MMTableViewCell
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
if (self) {
[self setAccessoryCheckmarkColor:[UIColor whiteColor]];
[self setDisclosureIndicatorColor:[UIColor whiteColor]];
[self updateContentForNewContentSize];
}
return self;
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated
{
[super setSelected:selected animated:animated];
// Configure the view for the selected state
}
- (void)setAccessoryType:(UITableViewCellAccessoryType)accessoryType{
[super setAccessoryType:accessoryType];
if(accessoryType == UITableViewCellAccessoryCheckmark){
MMCustomCheckmark * customCheckmark = [[MMCustomCheckmark alloc] initWithFrame:CGRectMake(0, 0, 15, 15)];
[customCheckmark setColor:self.accessoryCheckmarkColor];
[self setAccessoryView:customCheckmark];
}
else if(accessoryType == UITableViewCellAccessoryDisclosureIndicator){
MMDisclosureIndicator * di = [[MMDisclosureIndicator alloc] initWithFrame:CGRectMake(0, 0, 10, 14)];
[di setColor:self.disclosureIndicatorColor];
[self setAccessoryView:di];
}
else {
[self setAccessoryView:nil];
}
}
-(void)prepareForReuse{
[super prepareForReuse];
[self updateContentForNewContentSize];
}
-(void)updateContentForNewContentSize{
}
@end
================================================
FILE: KitchenSink/ExampleFiles/en.lproj/InfoPlist.strings
================================================
/* Localized versions of Info.plist keys */
================================================
FILE: KitchenSink/ExampleFiles/main.m
================================================
// Copyright (c) 2013 Mutual Mobile (http://mutualmobile.com/)
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
#import
#import "MMAppDelegate.h"
int main(int argc, char *argv[])
{
@autoreleasepool {
return UIApplicationMain(argc, argv, nil, NSStringFromClass([MMAppDelegate class]));
}
}
================================================
FILE: KitchenSink/MMDrawerControllerKitchenSink.xcodeproj/project.pbxproj
================================================
// !$*UTF8*$!
{
archiveVersion = 1;
classes = {
};
objectVersion = 46;
objects = {
/* Begin PBXBuildFile section */
294A1D1117199537005BF6B1 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 294A1D1017199537005BF6B1 /* UIKit.framework */; };
294A1D1317199537005BF6B1 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 294A1D1217199537005BF6B1 /* Foundation.framework */; };
294A1D1517199537005BF6B1 /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 294A1D1417199537005BF6B1 /* CoreGraphics.framework */; };
294A1D1B17199537005BF6B1 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 294A1D1917199537005BF6B1 /* InfoPlist.strings */; };
294A1D1D17199537005BF6B1 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 294A1D1C17199537005BF6B1 /* main.m */; };
294A1D2117199537005BF6B1 /* MMAppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 294A1D2017199537005BF6B1 /* MMAppDelegate.m */; };
294A1D301719982B005BF6B1 /* MMDrawerController.m in Sources */ = {isa = PBXBuildFile; fileRef = 294A1D2F1719982B005BF6B1 /* MMDrawerController.m */; };
294A1D3317199844005BF6B1 /* UIViewController+MMDrawerController.m in Sources */ = {isa = PBXBuildFile; fileRef = 294A1D3217199844005BF6B1 /* UIViewController+MMDrawerController.m */; };
2961190717383AFC00CD4063 /* MMLogoView.m in Sources */ = {isa = PBXBuildFile; fileRef = 2961190617383AFC00CD4063 /* MMLogoView.m */; };
2961190A1738416400CD4063 /* MMCenterTableViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 296119091738416400CD4063 /* MMCenterTableViewCell.m */; };
2969636C1738141500281B9A /* MMSideDrawerTableViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 2969636B1738141500281B9A /* MMSideDrawerTableViewCell.m */; };
297EA0051738112A00472DF4 /* MMTableViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 297EA0041738112A00472DF4 /* MMTableViewCell.m */; };
29848B5F173015D3006D8502 /* MMExampleLeftSideDrawerViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 29848B5E173015D3006D8502 /* MMExampleLeftSideDrawerViewController.m */; };
29848B6517301793006D8502 /* MMExampleRightSideDrawerViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 29848B6417301793006D8502 /* MMExampleRightSideDrawerViewController.m */; };
29971C901AB09A9F00D84C7B /* LaunchScreen.xib in Resources */ = {isa = PBXBuildFile; fileRef = 29971C8F1AB09A9F00D84C7B /* LaunchScreen.xib */; };
299E0ADD1738173B009FAA3C /* MMSideDrawerSectionHeaderView.m in Sources */ = {isa = PBXBuildFile; fileRef = 299E0ADC1738173B009FAA3C /* MMSideDrawerSectionHeaderView.m */; };
29C28481172AD77D0089E872 /* QuartzCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 29C28480172AD77D0089E872 /* QuartzCore.framework */; };
29C28487172B07C10089E872 /* MMExampleCenterTableViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 29C28486172B07C10089E872 /* MMExampleCenterTableViewController.m */; };
29C2848D172EB1710089E872 /* MMExampleSideDrawerViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 29C2848C172EB1710089E872 /* MMExampleSideDrawerViewController.m */; };
29CFD5EC173192D100E1FABB /* MMDrawerVisualState.m in Sources */ = {isa = PBXBuildFile; fileRef = 29CFD5EB173192D100E1FABB /* MMDrawerVisualState.m */; };
29CFD5EF1731C7DB00E1FABB /* MMExampleDrawerVisualStateManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 29CFD5EE1731C7DB00E1FABB /* MMExampleDrawerVisualStateManager.m */; };
29E2C6181738A10F00606309 /* Icon-72.png in Resources */ = {isa = PBXBuildFile; fileRef = 29E2C6141738A10F00606309 /* Icon-72.png */; };
29E2C6191738A10F00606309 /* Icon-72@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 29E2C6151738A10F00606309 /* Icon-72@2x.png */; };
29E2C61A1738A10F00606309 /* Icon.png in Resources */ = {isa = PBXBuildFile; fileRef = 29E2C6161738A10F00606309 /* Icon.png */; };
29E2C61B1738A10F00606309 /* Icon@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 29E2C6171738A10F00606309 /* Icon@2x.png */; };
29EEA51B17998320006D68B7 /* MMNavigationController.m in Sources */ = {isa = PBXBuildFile; fileRef = 29EEA51A17998320006D68B7 /* MMNavigationController.m */; };
29EEA51E1799923E006D68B7 /* MMExampleViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 29EEA51D1799923E006D68B7 /* MMExampleViewController.m */; };
29F6163B172AC22A00B31282 /* MMDrawerBarButtonItem.m in Sources */ = {isa = PBXBuildFile; fileRef = 29F6163A172AC22A00B31282 /* MMDrawerBarButtonItem.m */; };
/* End PBXBuildFile section */
/* Begin PBXFileReference section */
294A1D0D17199537005BF6B1 /* MMDrawerControllerKitchenSink.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = MMDrawerControllerKitchenSink.app; sourceTree = BUILT_PRODUCTS_DIR; };
294A1D1017199537005BF6B1 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; };
294A1D1217199537005BF6B1 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; };
294A1D1417199537005BF6B1 /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; };
294A1D1817199537005BF6B1 /* MMDrawerControllerKitchenSink-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "MMDrawerControllerKitchenSink-Info.plist"; sourceTree = ""; };
294A1D1A17199537005BF6B1 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = ""; };
294A1D1C17199537005BF6B1 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; };
294A1D1E17199537005BF6B1 /* MMDrawerControllerKitchenSink-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "MMDrawerControllerKitchenSink-Prefix.pch"; sourceTree = ""; };
294A1D1F17199537005BF6B1 /* MMAppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MMAppDelegate.h; sourceTree = ""; };
294A1D2017199537005BF6B1 /* MMAppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MMAppDelegate.m; sourceTree = ""; };
294A1D2E1719982B005BF6B1 /* MMDrawerController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MMDrawerController.h; sourceTree = ""; };
294A1D2F1719982B005BF6B1 /* MMDrawerController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MMDrawerController.m; sourceTree = ""; };
294A1D3117199844005BF6B1 /* UIViewController+MMDrawerController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIViewController+MMDrawerController.h"; sourceTree = ""; };
294A1D3217199844005BF6B1 /* UIViewController+MMDrawerController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIViewController+MMDrawerController.m"; sourceTree = ""; };
2961190517383AFC00CD4063 /* MMLogoView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MMLogoView.h; sourceTree = ""; };
2961190617383AFC00CD4063 /* MMLogoView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MMLogoView.m; sourceTree = ""; };
296119081738416400CD4063 /* MMCenterTableViewCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MMCenterTableViewCell.h; sourceTree = ""; };
296119091738416400CD4063 /* MMCenterTableViewCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MMCenterTableViewCell.m; sourceTree = ""; };
2969636A1738141500281B9A /* MMSideDrawerTableViewCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MMSideDrawerTableViewCell.h; sourceTree = ""; };
2969636B1738141500281B9A /* MMSideDrawerTableViewCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MMSideDrawerTableViewCell.m; sourceTree = ""; };
297EA0031738112A00472DF4 /* MMTableViewCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MMTableViewCell.h; sourceTree = ""; };
297EA0041738112A00472DF4 /* MMTableViewCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MMTableViewCell.m; sourceTree = ""; };
29848B5D173015D3006D8502 /* MMExampleLeftSideDrawerViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MMExampleLeftSideDrawerViewController.h; sourceTree = ""; };
29848B5E173015D3006D8502 /* MMExampleLeftSideDrawerViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MMExampleLeftSideDrawerViewController.m; sourceTree = ""; };
29848B6317301793006D8502 /* MMExampleRightSideDrawerViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MMExampleRightSideDrawerViewController.h; sourceTree = ""; };
29848B6417301793006D8502 /* MMExampleRightSideDrawerViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MMExampleRightSideDrawerViewController.m; sourceTree = ""; };
29971C8F1AB09A9F00D84C7B /* LaunchScreen.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = LaunchScreen.xib; sourceTree = ""; };
299E0ADB1738173B009FAA3C /* MMSideDrawerSectionHeaderView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MMSideDrawerSectionHeaderView.h; sourceTree = ""; };
299E0ADC1738173B009FAA3C /* MMSideDrawerSectionHeaderView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MMSideDrawerSectionHeaderView.m; sourceTree = ""; };
29C28480172AD77D0089E872 /* QuartzCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = QuartzCore.framework; path = System/Library/Frameworks/QuartzCore.framework; sourceTree = SDKROOT; };
29C28485172B07C10089E872 /* MMExampleCenterTableViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MMExampleCenterTableViewController.h; sourceTree = ""; };
29C28486172B07C10089E872 /* MMExampleCenterTableViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MMExampleCenterTableViewController.m; sourceTree = ""; };
29C2848B172EB1710089E872 /* MMExampleSideDrawerViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MMExampleSideDrawerViewController.h; sourceTree = ""; };
29C2848C172EB1710089E872 /* MMExampleSideDrawerViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MMExampleSideDrawerViewController.m; sourceTree = ""; };
29CFD5EA173192D100E1FABB /* MMDrawerVisualState.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MMDrawerVisualState.h; sourceTree = ""; };
29CFD5EB173192D100E1FABB /* MMDrawerVisualState.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MMDrawerVisualState.m; sourceTree = ""; };
29CFD5ED1731C7DB00E1FABB /* MMExampleDrawerVisualStateManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MMExampleDrawerVisualStateManager.h; sourceTree = ""; };
29CFD5EE1731C7DB00E1FABB /* MMExampleDrawerVisualStateManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MMExampleDrawerVisualStateManager.m; sourceTree = ""; };
29E2C6141738A10F00606309 /* Icon-72.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Icon-72.png"; sourceTree = ""; };
29E2C6151738A10F00606309 /* Icon-72@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Icon-72@2x.png"; sourceTree = ""; };
29E2C6161738A10F00606309 /* Icon.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = Icon.png; sourceTree = ""; };
29E2C6171738A10F00606309 /* Icon@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Icon@2x.png"; sourceTree = ""; };
29EEA51917998320006D68B7 /* MMNavigationController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MMNavigationController.h; sourceTree = ""; };
29EEA51A17998320006D68B7 /* MMNavigationController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MMNavigationController.m; sourceTree = ""; };
29EEA51C1799923E006D68B7 /* MMExampleViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MMExampleViewController.h; sourceTree = ""; };
29EEA51D1799923E006D68B7 /* MMExampleViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MMExampleViewController.m; sourceTree = ""; };
29F61639172AC22A00B31282 /* MMDrawerBarButtonItem.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MMDrawerBarButtonItem.h; sourceTree = ""; };
29F6163A172AC22A00B31282 /* MMDrawerBarButtonItem.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MMDrawerBarButtonItem.m; sourceTree = ""; };
462C592D1757C16B006C1D6F /* MMDrawerController+Subclass.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "MMDrawerController+Subclass.h"; sourceTree = ""; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
294A1D0A17199537005BF6B1 /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
29C28481172AD77D0089E872 /* QuartzCore.framework in Frameworks */,
294A1D1117199537005BF6B1 /* UIKit.framework in Frameworks */,
294A1D1317199537005BF6B1 /* Foundation.framework in Frameworks */,
294A1D1517199537005BF6B1 /* CoreGraphics.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXFrameworksBuildPhase section */
/* Begin PBXGroup section */
294A1D0417199537005BF6B1 = {
isa = PBXGroup;
children = (
294A1D2D17199819005BF6B1 /* MMDrawerController */,
294A1D1617199537005BF6B1 /* ExampleFiles */,
294A1D0F17199537005BF6B1 /* Frameworks */,
294A1D0E17199537005BF6B1 /* Products */,
);
sourceTree = "";
};
294A1D0E17199537005BF6B1 /* Products */ = {
isa = PBXGroup;
children = (
294A1D0D17199537005BF6B1 /* MMDrawerControllerKitchenSink.app */,
);
name = Products;
sourceTree = "";
};
294A1D0F17199537005BF6B1 /* Frameworks */ = {
isa = PBXGroup;
children = (
29C28480172AD77D0089E872 /* QuartzCore.framework */,
294A1D1017199537005BF6B1 /* UIKit.framework */,
294A1D1217199537005BF6B1 /* Foundation.framework */,
294A1D1417199537005BF6B1 /* CoreGraphics.framework */,
);
name = Frameworks;
sourceTree = "";
};
294A1D1617199537005BF6B1 /* ExampleFiles */ = {
isa = PBXGroup;
children = (
294A1D1F17199537005BF6B1 /* MMAppDelegate.h */,
294A1D2017199537005BF6B1 /* MMAppDelegate.m */,
2961190E173845FD00CD4063 /* VisualStateManager */,
2961190D173845EF00CD4063 /* CustomViews */,
2961190C173845E000CD4063 /* ViewControllers */,
2961190B173845D100CD4063 /* TableViewHelpers */,
294A1D1717199537005BF6B1 /* Supporting Files */,
);
path = ExampleFiles;
sourceTree = "";
};
294A1D1717199537005BF6B1 /* Supporting Files */ = {
isa = PBXGroup;
children = (
29E2C6131738A10F00606309 /* Icons */,
294A1D1817199537005BF6B1 /* MMDrawerControllerKitchenSink-Info.plist */,
294A1D1917199537005BF6B1 /* InfoPlist.strings */,
294A1D1C17199537005BF6B1 /* main.m */,
294A1D1E17199537005BF6B1 /* MMDrawerControllerKitchenSink-Prefix.pch */,
29971C8F1AB09A9F00D84C7B /* LaunchScreen.xib */,
);
name = "Supporting Files";
sourceTree = "";
};
294A1D2D17199819005BF6B1 /* MMDrawerController */ = {
isa = PBXGroup;
children = (
294A1D2E1719982B005BF6B1 /* MMDrawerController.h */,
294A1D2F1719982B005BF6B1 /* MMDrawerController.m */,
462C592D1757C16B006C1D6F /* MMDrawerController+Subclass.h */,
294A1D3117199844005BF6B1 /* UIViewController+MMDrawerController.h */,
294A1D3217199844005BF6B1 /* UIViewController+MMDrawerController.m */,
29F61639172AC22A00B31282 /* MMDrawerBarButtonItem.h */,
29F6163A172AC22A00B31282 /* MMDrawerBarButtonItem.m */,
29CFD5EA173192D100E1FABB /* MMDrawerVisualState.h */,
29CFD5EB173192D100E1FABB /* MMDrawerVisualState.m */,
);
name = MMDrawerController;
path = ../MMDrawerController;
sourceTree = "";
};
2961190B173845D100CD4063 /* TableViewHelpers */ = {
isa = PBXGroup;
children = (
297EA0031738112A00472DF4 /* MMTableViewCell.h */,
297EA0041738112A00472DF4 /* MMTableViewCell.m */,
2969636A1738141500281B9A /* MMSideDrawerTableViewCell.h */,
2969636B1738141500281B9A /* MMSideDrawerTableViewCell.m */,
296119081738416400CD4063 /* MMCenterTableViewCell.h */,
296119091738416400CD4063 /* MMCenterTableViewCell.m */,
299E0ADB1738173B009FAA3C /* MMSideDrawerSectionHeaderView.h */,
299E0ADC1738173B009FAA3C /* MMSideDrawerSectionHeaderView.m */,
);
name = TableViewHelpers;
sourceTree = "";
};
2961190C173845E000CD4063 /* ViewControllers */ = {
isa = PBXGroup;
children = (
29C28485172B07C10089E872 /* MMExampleCenterTableViewController.h */,
29C28486172B07C10089E872 /* MMExampleCenterTableViewController.m */,
29C2848B172EB1710089E872 /* MMExampleSideDrawerViewController.h */,
29C2848C172EB1710089E872 /* MMExampleSideDrawerViewController.m */,
29848B5D173015D3006D8502 /* MMExampleLeftSideDrawerViewController.h */,
29848B5E173015D3006D8502 /* MMExampleLeftSideDrawerViewController.m */,
29848B6317301793006D8502 /* MMExampleRightSideDrawerViewController.h */,
29848B6417301793006D8502 /* MMExampleRightSideDrawerViewController.m */,
29EEA51C1799923E006D68B7 /* MMExampleViewController.h */,
29EEA51D1799923E006D68B7 /* MMExampleViewController.m */,
29EEA51917998320006D68B7 /* MMNavigationController.h */,
29EEA51A17998320006D68B7 /* MMNavigationController.m */,
);
name = ViewControllers;
sourceTree = "";
};
2961190D173845EF00CD4063 /* CustomViews */ = {
isa = PBXGroup;
children = (
2961190517383AFC00CD4063 /* MMLogoView.h */,
2961190617383AFC00CD4063 /* MMLogoView.m */,
);
name = CustomViews;
sourceTree = "";
};
2961190E173845FD00CD4063 /* VisualStateManager */ = {
isa = PBXGroup;
children = (
29CFD5ED1731C7DB00E1FABB /* MMExampleDrawerVisualStateManager.h */,
29CFD5EE1731C7DB00E1FABB /* MMExampleDrawerVisualStateManager.m */,
);
name = VisualStateManager;
sourceTree = "";
};
29E2C6131738A10F00606309 /* Icons */ = {
isa = PBXGroup;
children = (
29E2C6141738A10F00606309 /* Icon-72.png */,
29E2C6151738A10F00606309 /* Icon-72@2x.png */,
29E2C6161738A10F00606309 /* Icon.png */,
29E2C6171738A10F00606309 /* Icon@2x.png */,
);
path = Icons;
sourceTree = SOURCE_ROOT;
};
/* End PBXGroup section */
/* Begin PBXNativeTarget section */
294A1D0C17199537005BF6B1 /* MMDrawerControllerKitchenSink */ = {
isa = PBXNativeTarget;
buildConfigurationList = 294A1D2A17199537005BF6B1 /* Build configuration list for PBXNativeTarget "MMDrawerControllerKitchenSink" */;
buildPhases = (
294A1D0917199537005BF6B1 /* Sources */,
294A1D0A17199537005BF6B1 /* Frameworks */,
294A1D0B17199537005BF6B1 /* Resources */,
);
buildRules = (
);
dependencies = (
);
name = MMDrawerControllerKitchenSink;
productName = MMSideDrawerContainerViewController;
productReference = 294A1D0D17199537005BF6B1 /* MMDrawerControllerKitchenSink.app */;
productType = "com.apple.product-type.application";
};
/* End PBXNativeTarget section */
/* Begin PBXProject section */
294A1D0517199537005BF6B1 /* Project object */ = {
isa = PBXProject;
attributes = {
CLASSPREFIX = MM;
LastUpgradeCheck = 0460;
ORGANIZATIONNAME = "Mutual Mobile";
};
buildConfigurationList = 294A1D0817199537005BF6B1 /* Build configuration list for PBXProject "MMDrawerControllerKitchenSink" */;
compatibilityVersion = "Xcode 3.2";
developmentRegion = English;
hasScannedForEncodings = 0;
knownRegions = (
en,
);
mainGroup = 294A1D0417199537005BF6B1;
productRefGroup = 294A1D0E17199537005BF6B1 /* Products */;
projectDirPath = "";
projectRoot = "";
targets = (
294A1D0C17199537005BF6B1 /* MMDrawerControllerKitchenSink */,
);
};
/* End PBXProject section */
/* Begin PBXResourcesBuildPhase section */
294A1D0B17199537005BF6B1 /* Resources */ = {
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
294A1D1B17199537005BF6B1 /* InfoPlist.strings in Resources */,
29E2C6181738A10F00606309 /* Icon-72.png in Resources */,
29E2C6191738A10F00606309 /* Icon-72@2x.png in Resources */,
29E2C61A1738A10F00606309 /* Icon.png in Resources */,
29971C901AB09A9F00D84C7B /* LaunchScreen.xib in Resources */,
29E2C61B1738A10F00606309 /* Icon@2x.png in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXResourcesBuildPhase section */
/* Begin PBXSourcesBuildPhase section */
294A1D0917199537005BF6B1 /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
294A1D1D17199537005BF6B1 /* main.m in Sources */,
294A1D2117199537005BF6B1 /* MMAppDelegate.m in Sources */,
294A1D301719982B005BF6B1 /* MMDrawerController.m in Sources */,
294A1D3317199844005BF6B1 /* UIViewController+MMDrawerController.m in Sources */,
29F6163B172AC22A00B31282 /* MMDrawerBarButtonItem.m in Sources */,
29C28487172B07C10089E872 /* MMExampleCenterTableViewController.m in Sources */,
29C2848D172EB1710089E872 /* MMExampleSideDrawerViewController.m in Sources */,
29848B5F173015D3006D8502 /* MMExampleLeftSideDrawerViewController.m in Sources */,
29EEA51E1799923E006D68B7 /* MMExampleViewController.m in Sources */,
29848B6517301793006D8502 /* MMExampleRightSideDrawerViewController.m in Sources */,
29CFD5EC173192D100E1FABB /* MMDrawerVisualState.m in Sources */,
29EEA51B17998320006D68B7 /* MMNavigationController.m in Sources */,
29CFD5EF1731C7DB00E1FABB /* MMExampleDrawerVisualStateManager.m in Sources */,
297EA0051738112A00472DF4 /* MMTableViewCell.m in Sources */,
2969636C1738141500281B9A /* MMSideDrawerTableViewCell.m in Sources */,
299E0ADD1738173B009FAA3C /* MMSideDrawerSectionHeaderView.m in Sources */,
2961190717383AFC00CD4063 /* MMLogoView.m in Sources */,
2961190A1738416400CD4063 /* MMCenterTableViewCell.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXSourcesBuildPhase section */
/* Begin PBXVariantGroup section */
294A1D1917199537005BF6B1 /* InfoPlist.strings */ = {
isa = PBXVariantGroup;
children = (
294A1D1A17199537005BF6B1 /* en */,
);
name = InfoPlist.strings;
sourceTree = "";
};
/* End PBXVariantGroup section */
/* Begin XCBuildConfiguration section */
294A1D2817199537005BF6B1 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
COPY_PHASE_STRIP = NO;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_DYNAMIC_NO_PIC = NO;
GCC_OPTIMIZATION_LEVEL = 0;
GCC_PREPROCESSOR_DEFINITIONS = (
"DEBUG=1",
"$(inherited)",
);
GCC_SYMBOLS_PRIVATE_EXTERN = NO;
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 6.1;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Debug;
};
294A1D2917199537005BF6B1 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
COPY_PHASE_STRIP = YES;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 6.1;
OTHER_CFLAGS = "-DNS_BLOCK_ASSERTIONS=1";
SDKROOT = iphoneos;
TARGETED_DEVICE_FAMILY = "1,2";
VALIDATE_PRODUCT = YES;
};
name = Release;
};
294A1D2B17199537005BF6B1 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "ExampleFiles/MMDrawerControllerKitchenSink-Prefix.pch";
INFOPLIST_FILE = "ExampleFiles/MMDrawerControllerKitchenSink-Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 7.0;
PRODUCT_NAME = MMDrawerControllerKitchenSink;
WARNING_CFLAGS = "-Wdocumentation";
WRAPPER_EXTENSION = app;
};
name = Debug;
};
294A1D2C17199537005BF6B1 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "ExampleFiles/MMDrawerControllerKitchenSink-Prefix.pch";
INFOPLIST_FILE = "ExampleFiles/MMDrawerControllerKitchenSink-Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 7.0;
PRODUCT_NAME = MMDrawerControllerKitchenSink;
WARNING_CFLAGS = "-Wdocumentation";
WRAPPER_EXTENSION = app;
};
name = Release;
};
/* End XCBuildConfiguration section */
/* Begin XCConfigurationList section */
294A1D0817199537005BF6B1 /* Build configuration list for PBXProject "MMDrawerControllerKitchenSink" */ = {
isa = XCConfigurationList;
buildConfigurations = (
294A1D2817199537005BF6B1 /* Debug */,
294A1D2917199537005BF6B1 /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
294A1D2A17199537005BF6B1 /* Build configuration list for PBXNativeTarget "MMDrawerControllerKitchenSink" */ = {
isa = XCConfigurationList;
buildConfigurations = (
294A1D2B17199537005BF6B1 /* Debug */,
294A1D2C17199537005BF6B1 /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
/* End XCConfigurationList section */
};
rootObject = 294A1D0517199537005BF6B1 /* Project object */;
}
================================================
FILE: KitchenSink/MMDrawerControllerKitchenSink.xcodeproj/project.xcworkspace/contents.xcworkspacedata
================================================
================================================
FILE: KitchenSink/MMDrawerControllerKitchenSink.xcodeproj/project.xcworkspace/xcshareddata/MMDrawerControllerKitchenSink.xccheckout
================================================
IDESourceControlProjectFavoriteDictionaryKeyIDESourceControlProjectIdentifier88813EDE-C4BC-4EAD-BA3F-F5FC71109468IDESourceControlProjectNameMMDrawerControllerKitchenSinkIDESourceControlProjectOriginsDictionaryBF2FE30DD30E807A424B26D63A15FEB4A29593EBhttps://github.com/mutualmobile/MMDrawerController.gitIDESourceControlProjectPathKitchenSink/MMDrawerControllerKitchenSink.xcodeprojIDESourceControlProjectRelativeInstallPathDictionaryBF2FE30DD30E807A424B26D63A15FEB4A29593EB../../..IDESourceControlProjectURLhttps://github.com/mutualmobile/MMDrawerController.gitIDESourceControlProjectVersion111IDESourceControlProjectWCCIdentifierBF2FE30DD30E807A424B26D63A15FEB4A29593EBIDESourceControlProjectWCConfigurationsIDESourceControlRepositoryExtensionIdentifierKeypublic.vcs.gitIDESourceControlWCCIdentifierKeyBF2FE30DD30E807A424B26D63A15FEB4A29593EBIDESourceControlWCCNameMMDrawerController-GitHub
================================================
FILE: KitchenSink/MMDrawerControllerKitchenSink.xcodeproj/xcshareddata/xcschemes/MMDrawerControllerKitchenSink.xcscheme
================================================
================================================
FILE: LICENSE
================================================
Copyright (c) 2013 Mutual Mobile (http://mutualmobile.com/)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
================================================
FILE: MMDrawerController/MMDrawerBarButtonItem.h
================================================
// Copyright (c) 2013 Mutual Mobile (http://mutualmobile.com/)
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
#import
/**
`MMDrawerBarButtonItem` provides convenience methods to create `UIBarButtonItems` with a default hamburger-menu asset.
*/
@interface MMDrawerBarButtonItem : UIBarButtonItem
///---------------------------------------
/// @name Initializing a `MMDrawerBarButtonItem`
///---------------------------------------
/**
Creates and initializes an `MMDrawerBarButtonItem` without a border.
@param target The target to forward the `action` to when the button is pressed.
@param action The action to call when the button is pressed.
@return The newly-initialized bar button item.
*/
-(instancetype)initWithTarget:(id)target action:(SEL)action;
/**
Returns the current color of the menu button for the state requested. This property is deprecated in iOS 7.0. Use `tintColor` instead.
@param state The UIControl state that the color is being requested for.
@return The menu button color for the requested state.
*/
-(UIColor *)menuButtonColorForState:(UIControlState)state __attribute__((deprecated("Use tintColor instead")));
/**
Sets the color of the menu button for the specified state. For this control, only set colors for `UIControlStateNormal` and `UIControlStateHighlighted`. This property is deprecated in iOS 7.0. Use `tintColor` instead.
@param color The color to set.
@param state The state to set the color for.
*/
-(void)setMenuButtonColor:(UIColor *)color forState:(UIControlState)state __attribute__((deprecated("Use tintColor instead")));
/**
Returns the current color of the shadow for the state requested. This property is deprecated in iOS 7.0. The menu button no longer supports a shadow.
@param state The UIControl state that the color is being requested for.
@return The menu button color for the requested state.
*/
-(UIColor *)shadowColorForState:(UIControlState)state __attribute__((deprecated("Shadow is no longer supported")));
/**
Sets the color of the shadow for the specified state. For this control, only set colors for `UIControlStateNormal` and `UIControlStateHighlighted`. This property is deprecated in iOS 7.0. The menu button no longer supports a shadow.
@param color The color to set.
@param state The state to set the color for.
*/
-(void)setShadowColor:(UIColor *)color forState:(UIControlState)state __attribute__((deprecated("Shadow is no longer supported")));
@end
================================================
FILE: MMDrawerController/MMDrawerBarButtonItem.m
================================================
// Copyright (c) 2013 Mutual Mobile (http://mutualmobile.com/)
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
#import "MMDrawerBarButtonItem.h"
@interface MMDrawerMenuButtonView : UIButton
@property (nonatomic,strong) UIColor * menuButtonNormalColor;
@property (nonatomic,strong) UIColor * menuButtonHighlightedColor;
@property (nonatomic,strong) UIColor * shadowNormalColor;
@property (nonatomic,strong) UIColor * shadowHighlightedColor;
-(UIColor *)menuButtonColorForState:(UIControlState)state;
-(void)setMenuButtonColor:(UIColor *)color forState:(UIControlState)state;
-(UIColor *)shadowColorForState:(UIControlState)state;
-(void)setShadowColor:(UIColor *)color forState:(UIControlState)state;
@end
@implementation MMDrawerMenuButtonView
-(instancetype)initWithFrame:(CGRect)frame{
self = [super initWithFrame:frame];
if(self){
[self setMenuButtonNormalColor:[[UIColor whiteColor] colorWithAlphaComponent:0.9f]];
[self setMenuButtonHighlightedColor:[UIColor colorWithRed:139.0/255.0
green:135.0/255.0
blue:136.0/255.0
alpha:0.9f]];
[self setShadowNormalColor:[[UIColor blackColor] colorWithAlphaComponent:0.5f]];
[self setShadowHighlightedColor:[[UIColor blackColor] colorWithAlphaComponent:0.2f]];
}
return self;
}
-(UIColor *)menuButtonColorForState:(UIControlState)state{
UIColor * color;
switch (state) {
case UIControlStateNormal:
color = self.menuButtonNormalColor;
break;
case UIControlStateHighlighted:
color = self.menuButtonHighlightedColor;
break;
default:
break;
}
return color;
}
-(void)setMenuButtonColor:(UIColor *)color forState:(UIControlState)state{
switch (state) {
case UIControlStateNormal:
[self setMenuButtonNormalColor:color];
break;
case UIControlStateHighlighted:
[self setMenuButtonHighlightedColor:color];
break;
default:
break;
}
[self setNeedsDisplay];
}
-(UIColor *)shadowColorForState:(UIControlState)state{
UIColor * color;
switch (state) {
case UIControlStateNormal:
color = self.shadowNormalColor;
break;
case UIControlStateHighlighted:
color = self.shadowHighlightedColor;
break;
default:
break;
}
return color;
}
-(void)setShadowColor:(UIColor *)color forState:(UIControlState)state{
switch (state) {
case UIControlStateNormal:
[self setShadowNormalColor:color];
break;
case UIControlStateHighlighted:
[self setShadowHighlightedColor:color];
break;
default:
break;
}
[self setNeedsDisplay];
}
-(void)drawRect:(CGRect)rect{
//// General Declarations
CGContextRef context = UIGraphicsGetCurrentContext();
//Sizes
CGFloat buttonWidth = CGRectGetWidth(self.bounds)*.80;
CGFloat buttonHeight = CGRectGetHeight(self.bounds)*.16;
CGFloat xOffset = CGRectGetWidth(self.bounds)*.10;
CGFloat yOffset = CGRectGetHeight(self.bounds)*.12;
CGFloat cornerRadius = 1.0;
//// Color Declarations
UIColor* buttonColor = [self menuButtonColorForState:self.state];
UIColor* shadowColor = [self shadowColorForState:self.state];
//// Shadow Declarations
UIColor* shadow = shadowColor;
CGSize shadowOffset = CGSizeMake(0.0, 1.0);
CGFloat shadowBlurRadius = 0;
//// Top Bun Drawing
UIBezierPath* topBunPath = [UIBezierPath bezierPathWithRoundedRect:CGRectMake(xOffset, yOffset, buttonWidth, buttonHeight) cornerRadius:cornerRadius];
CGContextSaveGState(context);
CGContextSetShadowWithColor(context, shadowOffset, shadowBlurRadius, shadow.CGColor);
[buttonColor setFill];
[topBunPath fill];
CGContextRestoreGState(context);
//// Meat Drawing
UIBezierPath* meatPath = [UIBezierPath bezierPathWithRoundedRect:CGRectMake(xOffset, yOffset*2 + buttonHeight, buttonWidth, buttonHeight) cornerRadius:cornerRadius];
CGContextSaveGState(context);
CGContextSetShadowWithColor(context, shadowOffset, shadowBlurRadius, shadow.CGColor);
[buttonColor setFill];
[meatPath fill];
CGContextRestoreGState(context);
//// Bottom Bun Drawing
UIBezierPath* bottomBunPath = [UIBezierPath bezierPathWithRoundedRect:CGRectMake(xOffset, yOffset*3 + buttonHeight*2, buttonWidth, buttonHeight) cornerRadius:cornerRadius];
CGContextSaveGState(context);
CGContextSetShadowWithColor(context, shadowOffset, shadowBlurRadius, shadow.CGColor);
[buttonColor setFill];
[bottomBunPath fill];
CGContextRestoreGState(context);
}
-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{
[super touchesBegan:touches withEvent:event];
[self setNeedsDisplay];
}
-(void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event{
[super touchesEnded:touches withEvent:event];
[self setNeedsDisplay];
}
-(void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event{
[super touchesCancelled:touches withEvent:event];
[self setNeedsDisplay];
}
-(void)setSelected:(BOOL)selected{
[super setSelected:selected];
[self setNeedsDisplay];
}
-(void)setHighlighted:(BOOL)highlighted{
[super setHighlighted:highlighted];
[self setNeedsDisplay];
}
-(void)setTintColor:(UIColor *)tintColor{
if([super respondsToSelector:@selector(setTintColor:)]){
[super setTintColor:tintColor];
}
}
-(void)tintColorDidChange{
[self setNeedsDisplay];
}
@end
@interface MMDrawerBarButtonItem ()
@property (nonatomic,strong) MMDrawerMenuButtonView * buttonView;
@end
@implementation MMDrawerBarButtonItem
+(UIImage*)drawerButtonItemImage{
static UIImage *drawerButtonImage = nil;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
UIGraphicsBeginImageContextWithOptions( CGSizeMake(26, 26), NO, 0 );
//// Color Declarations
UIColor* fillColor = [UIColor whiteColor];
//// Frames
CGRect frame = CGRectMake(0, 0, 26, 26);
//// Bottom Bar Drawing
UIBezierPath* bottomBarPath = [UIBezierPath bezierPathWithRect: CGRectMake(CGRectGetMinX(frame) + floor((CGRectGetWidth(frame) - 16) * 0.50000 + 0.5), CGRectGetMinY(frame) + floor((CGRectGetHeight(frame) - 1) * 0.72000 + 0.5), 16, 1)];
[fillColor setFill];
[bottomBarPath fill];
//// Middle Bar Drawing
UIBezierPath* middleBarPath = [UIBezierPath bezierPathWithRect: CGRectMake(CGRectGetMinX(frame) + floor((CGRectGetWidth(frame) - 16) * 0.50000 + 0.5), CGRectGetMinY(frame) + floor((CGRectGetHeight(frame) - 1) * 0.48000 + 0.5), 16, 1)];
[fillColor setFill];
[middleBarPath fill];
//// Top Bar Drawing
UIBezierPath* topBarPath = [UIBezierPath bezierPathWithRect: CGRectMake(CGRectGetMinX(frame) + floor((CGRectGetWidth(frame) - 16) * 0.50000 + 0.5), CGRectGetMinY(frame) + floor((CGRectGetHeight(frame) - 1) * 0.24000 + 0.5), 16, 1)];
[fillColor setFill];
[topBarPath fill];
drawerButtonImage = UIGraphicsGetImageFromCurrentImageContext();
});
return drawerButtonImage;
}
-(instancetype)initWithTarget:(id)target action:(SEL)action{
if((floor(NSFoundationVersionNumber) > NSFoundationVersionNumber_iOS_6_1)){
return [self initWithImage:[self.class drawerButtonItemImage]
style:UIBarButtonItemStylePlain
target:target
action:action];
}
else {
MMDrawerMenuButtonView * buttonView = [[MMDrawerMenuButtonView alloc] initWithFrame:CGRectMake(0, 0, 26, 26)];
[buttonView addTarget:self action:@selector(touchUpInside:) forControlEvents:UIControlEventTouchUpInside];
self = [self initWithCustomView:buttonView];
if(self){
[self setButtonView:buttonView];
}
self.action = action;
self.target = target;
return self;
}
}
-(instancetype)initWithCoder:(NSCoder *)aDecoder{
// non-ideal way to get the target/action, but it works
UIBarButtonItem* barButtonItem = [[UIBarButtonItem alloc] initWithCoder: aDecoder];
return [self initWithTarget:barButtonItem.target action:barButtonItem.action];
}
-(void)touchUpInside:(id)sender{
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Warc-performSelector-leaks"
[self.target performSelector:self.action withObject:sender];
#pragma clang diagnostic pop;
}
-(UIColor *)menuButtonColorForState:(UIControlState)state{
return [self.buttonView menuButtonColorForState:state];
}
-(void)setMenuButtonColor:(UIColor *)color forState:(UIControlState)state{
[self.buttonView setMenuButtonColor:color forState:state];
}
-(UIColor *)shadowColorForState:(UIControlState)state{
return [self.buttonView shadowColorForState:state];
}
-(void)setShadowColor:(UIColor *)color forState:(UIControlState)state{
[self.buttonView setShadowColor:color forState:state];
}
-(void)setTintColor:(UIColor *)tintColor{
if([super respondsToSelector:@selector(setTintColor:)]){
[super setTintColor:tintColor];
}
if([self.buttonView respondsToSelector:@selector(setTintColor:)]){
[self.buttonView setTintColor:tintColor];
}
}
@end
================================================
FILE: MMDrawerController/MMDrawerController+Subclass.h
================================================
// Copyright (c) 2013 Mutual Mobile (http://mutualmobile.com/)
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
#import "MMDrawerController.h"
/**
This class extension is designed for use by subclasses of `MMDrawerController` to customize the functionality to support a specific use-case by a developer. When importing this file, there is no need to also call `#import MMDrawerController.h`.
None of these methods are meant to be called by non-subclasses of `MMDrawerController`.
*/
@interface MMDrawerController (Subclass)
///---------------------------------------
/// @name Gesture Interaction
///---------------------------------------
/**
`MMDrawerController`'s single-tap gesture recognizer callback. This method is called every time the `UITapGestureRecognizer` is triggered.
@param tapGesture The single-tap gesture recognizer instance that triggered the callback
*/
-(void)tapGestureCallback:(UITapGestureRecognizer *)tapGesture __attribute((objc_requires_super));
/**
`MMDrawerController`'s pan gesture recognizer callback. This method is called every time the `UIPanGestureRecognizer` is updated.
@warning This method do the minimal amount of work to keep the pan gesture responsive.
@param panGesture The pan gesture recognizer instance that triggered the callback
*/
-(void)panGestureCallback:(UIPanGestureRecognizer *)panGesture __attribute((objc_requires_super));
/**
A `UIGestureRecognizerDelegate` method that is queried by `MMDrawerController`'s gestures to determine if it should receive the touch.
@param gestureRecognizer The gesture recognizer that is asking if it should recieve a touch
@param touch The touch in question in gestureRecognizer.view's coordinate space
*/
-(BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch __attribute((objc_requires_super));
///---------------------------------------
/// @name Drawer Presentation
///---------------------------------------
/**
Sets the initial conditions for `MMDrawerController` and its child view controllers to prepare the drawer for a transition. If a drawer is open and the opposite drawer is being presented, it prepares that drawer to be hidden and vice-versa for the closing drawer.
@param drawer The drawer side that will be presented
@param animated A boolean that indicates whether the presentation is being animated or not
*/
-(void)prepareToPresentDrawer:(MMDrawerSide)drawer animated:(BOOL)animated __attribute((objc_requires_super));
///---------------------------------------
/// @name Opening/Closing Drawer
///---------------------------------------
/**
The method that handles closing the drawer. You can subclass this method to get a callback every time the drawer is about to be closed. You can inspect the current open side to determine what side is about to be closed.
@param animated A boolean that indicates whether the drawer should close with animation
@param velocity A float indicating how fast the drawer should close
@param animationOptions A mask defining the animation options of the animation
@param completion A completion block to be called when the drawer is finished closing
*/
-(void)closeDrawerAnimated:(BOOL)animated velocity:(CGFloat)velocity animationOptions:(UIViewAnimationOptions)options completion:(void (^)(BOOL))completion __attribute((objc_requires_super));
/**
The method that handles opening the drawer. You can subclass this method to get a callback every time the drawer is about to be opened.
@param drawerSide The drawer side that will be opened
@param animated A boolean that indicates whether the drawer should open with animation
@param velocity A float indicating how fast the drawer should open
@param animationOptions A mask defining the animation options of the animation
@param completion A completion block to be called when the drawer is finished opening
*/
-(void)openDrawerSide:(MMDrawerSide)drawerSide animated:(BOOL)animated velocity:(CGFloat)velocity animationOptions:(UIViewAnimationOptions)options completion:(void (^)(BOOL))completion __attribute((objc_requires_super));
///---------------------------------------
/// @name `UIViewController` Subclass Methods
///---------------------------------------
/**
Included here to ensure subclasses call `super`.
@param toInterfaceOrientation The interface orientation that the interface is moving to
@param duration The duration of the interface orientation animation
*/
-(void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration __attribute((objc_requires_super));
/**
Included here to ensure subclasses call `super`.
@param toInterfaceOrientation The interface orientation that the interface is moving to
@param duration The duration of the interface orientation animation
*/
-(void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration __attribute((objc_requires_super));
@end
================================================
FILE: MMDrawerController/MMDrawerController.h
================================================
// Copyright (c) 2013 Mutual Mobile (http://mutualmobile.com/)
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
#import
/**
`MMDrawerController` is a side drawer navigation container view controller designed to support the growing number of applications that leverage the side drawer paradigm. This library is designed to exclusively support side drawer navigation in light-weight, focused approach.
## Creating a MMDrawerController
`MMDrawerController` is a container view controller, similiar to `UINavigationController` or `UITabBarController`, with up to three child view controllers - Center, LeftDrawer, and RightDrawer. To create a `MMDrawerController`, you must first instantiate the drawer view controllers and the initial center controller, then call one of the init methods listed in this class.
## Handling a UINavigationController as the centerViewController
`MMDrawerController` automatically supports handling a `UINavigationController` as the `centerViewController`, and will correctly handle the proper gestures on each view (the navigation bar view as well as the content view for the visible view controller). Note that while this library does support other container view controllers, the open/close gestures are not customized to support them.
## Accessing MMDrawerController from the Child View Controller
You can leverage the category class (UIViewController+MMDrawerController) included with this library to access information about the parent `MMDrawerController`. Note that if you are contained within a UINavigationController, the `drawerContainerViewController` will still return the proper reference to the `drawerContainerViewController` parent, even though it is not the direct parent. Refer to the documentation included with the category for more information.
## How MMDrawerOpenCenterInteractionMode is handled
`MMDrawerOpenCenterInteractionMode` controls how the user should be able to interact with the center view controller when either drawer is open. By default, this is set to `MMDrawerOpenCenterInteractionModeNavigationBarOnly`, which allows the user to interact with UINavigationBarItems while either drawer is open (typicaly used to click the menu button to close). If you set the interaction mode to `MMDrawerOpenCenterInteractionModeNone`, no items within the center view will be able to be interacted with while a drawer is open. Note that this setting has no effect at all on the `MMCloseDrawerGestureMode`.
## How Open/Close Gestures are handled
Two gestures are added to every instance of a drawer controller, one for pan and one for touch. `MMDrawerController` is the delegate for each of the gesture recoginzers, and determines if a touch should be sent to the appropriate gesture when a touch is detected compared with the masks set for open and close gestures and the state of the drawer controller.
## Integrating with State Restoration
In order to opt in to state restoration for `MMDrawerController`, you must set the `restorationIdentifier` of your drawer controller. Instances of your centerViewController, leftDrawerViewController and rightDrawerViewController must also be configured with their own `restorationIdentifier` (and optionally a restorationClass) if you intend for those to be restored as well. If your MMDrawerController had an open drawer when your app was sent to the background, that state will also be restored.
## What this library doesn't do.
This library is not meant for:
- Top or bottom drawer views
- Displaying both drawers at one time
- Displaying a minimum drawer width
- Support container view controllers other than `UINavigationController` as the center view controller.
*/
typedef NS_ENUM(NSInteger,MMDrawerSide){
MMDrawerSideNone = 0,
MMDrawerSideLeft,
MMDrawerSideRight,
};
typedef NS_OPTIONS(NSInteger, MMOpenDrawerGestureMode) {
MMOpenDrawerGestureModeNone = 0,
MMOpenDrawerGestureModePanningNavigationBar = 1 << 1,
MMOpenDrawerGestureModePanningCenterView = 1 << 2,
MMOpenDrawerGestureModeBezelPanningCenterView = 1 << 3,
MMOpenDrawerGestureModeCustom = 1 << 4,
MMOpenDrawerGestureModeAll = MMOpenDrawerGestureModePanningNavigationBar |
MMOpenDrawerGestureModePanningCenterView |
MMOpenDrawerGestureModeBezelPanningCenterView |
MMOpenDrawerGestureModeCustom,
};
typedef NS_OPTIONS(NSInteger, MMCloseDrawerGestureMode) {
MMCloseDrawerGestureModeNone = 0,
MMCloseDrawerGestureModePanningNavigationBar = 1 << 1,
MMCloseDrawerGestureModePanningCenterView = 1 << 2,
MMCloseDrawerGestureModeBezelPanningCenterView = 1 << 3,
MMCloseDrawerGestureModeTapNavigationBar = 1 << 4,
MMCloseDrawerGestureModeTapCenterView = 1 << 5,
MMCloseDrawerGestureModePanningDrawerView = 1 << 6,
MMCloseDrawerGestureModeCustom = 1 << 7,
MMCloseDrawerGestureModeAll = MMCloseDrawerGestureModePanningNavigationBar |
MMCloseDrawerGestureModePanningCenterView |
MMCloseDrawerGestureModeBezelPanningCenterView |
MMCloseDrawerGestureModeTapNavigationBar |
MMCloseDrawerGestureModeTapCenterView |
MMCloseDrawerGestureModePanningDrawerView |
MMCloseDrawerGestureModeCustom,
};
typedef NS_ENUM(NSInteger, MMDrawerOpenCenterInteractionMode) {
MMDrawerOpenCenterInteractionModeNone,
MMDrawerOpenCenterInteractionModeFull,
MMDrawerOpenCenterInteractionModeNavigationBarOnly,
};
@class MMDrawerController;
typedef void (^MMDrawerControllerDrawerVisualStateBlock)(MMDrawerController * drawerController, MMDrawerSide drawerSide, CGFloat percentVisible);
@interface MMDrawerController : UIViewController
///---------------------------------------
/// @name Accessing Drawer Container View Controller Properties
///---------------------------------------
/**
The center view controller.
This can only be set via the init methods, as well as the `setNewCenterViewController:...` methods. The size of this view controller will automatically be set to the size of the drawer container view controller, and it's position is modified from within this class. Do not modify the frame externally.
*/
@property (nonatomic, strong) UIViewController * centerViewController;
/**
The left drawer view controller.
The size of this view controller is managed within this class, and is automatically set to the appropriate size based on the `maximumLeftDrawerWidth`. Do not modify the frame externally.
*/
@property (nonatomic, strong) UIViewController * leftDrawerViewController;
/**
The right drawer view controller.
The size of this view controller is managed within this class, and is automatically set to the appropriate size based on the `maximumRightDrawerWidth`. Do not modify the frame externally.
*/
@property (nonatomic, strong) UIViewController * rightDrawerViewController;
/**
The maximum width of the `leftDrawerViewController`.
By default, this is set to 280. If the `leftDrawerViewController` is nil, this property will return 0.0;
*/
@property (nonatomic, assign) CGFloat maximumLeftDrawerWidth;
/**
The maximum width of the `rightDrawerViewController`.
By default, this is set to 280. If the `rightDrawerViewController` is nil, this property will return 0.0;
*/
@property (nonatomic, assign) CGFloat maximumRightDrawerWidth;
/**
The visible width of the `leftDrawerViewController`.
Note this value can be greater than `maximumLeftDrawerWidth` during the full close animation when setting a new center view controller;
*/
@property (nonatomic, assign, readonly) CGFloat visibleLeftDrawerWidth;
/**
The visible width of the `rightDrawerViewController`.
Note this value can be greater than `maximumRightDrawerWidth` during the full close animation when setting a new center view controller;
*/
@property (nonatomic, assign, readonly) CGFloat visibleRightDrawerWidth;
/**
The animation velocity of the open and close methods, measured in points per second.
By default, this is set to 840 points per second (three times the default drawer width), meaning it takes 1/3 of a second for the `centerViewController` to open/close across the default drawer width. Note that there is a minimum .1 second duration for built in animations, to account for small distance animations.
*/
@property (nonatomic, assign) CGFloat animationVelocity;
/**
A boolean that determines whether or not the panning gesture will "hard-stop" at the maximum width for a given drawer side.
By default, this value is set to YES. Enabling `shouldStretchDrawer` will give the pan a gradual asymptotic stopping point much like `UIScrollView` behaves. Note that if this value is set to YES, the `drawerVisualStateBlock` can be passed a `percentVisible` greater than 1.0, so be sure to handle that case appropriately.
*/
@property (nonatomic, assign) BOOL shouldStretchDrawer;
/**
The current open side of the drawer.
Note this value will change as soon as a pan gesture opens a drawer, or when a open/close animation is finished.
*/
@property (nonatomic, assign, readonly) MMDrawerSide openSide;
/**
How a user is allowed to open a drawer using gestures.
By default, this is set to `MMOpenDrawerGestureModeNone`. Note these gestures may affect user interaction with the `centerViewController`, so be sure to use appropriately.
*/
@property (nonatomic, assign) MMOpenDrawerGestureMode openDrawerGestureModeMask;
/**
How a user is allowed to close a drawer.
By default, this is set to `MMCloseDrawerGestureModeNone`. Note these gestures may affect user interaction with the `centerViewController`, so be sure to use appropriately.
*/
@property (nonatomic, assign) MMCloseDrawerGestureMode closeDrawerGestureModeMask;
/**
The value determining if the user can interact with the `centerViewController` when a side drawer is open.
By default, it is `MMDrawerOpenCenterInteractionModeNavigationBarOnly`, meaning that the user can only interact with the buttons on the `UINavigationBar`, if the center view controller is a `UINavigationController`. Otherwise, the user cannot interact with any other center view controller elements.
*/
@property (nonatomic, assign) MMDrawerOpenCenterInteractionMode centerHiddenInteractionMode;
/**
The flag determining if a shadow should be drawn off of `centerViewController` when a drawer is open.
By default, this is set to YES.
*/
@property (nonatomic, assign) BOOL showsShadow;
/**
The shadow radius of `centerViewController` when a drawer is open.
By default, this is set to 10.0f;
*/
@property (nonatomic, assign) CGFloat shadowRadius;
/**
The shadow opacity of `centerViewController` when a drawer is open.
By default, this is set to 0.8f;
*/
@property (nonatomic, assign) CGFloat shadowOpacity;
/**
The shadow offset of `centerViewController` when a drawer is open.
By default, this is set to (0, -3);
*/
@property (nonatomic, assign) CGSize shadowOffset;
/**
The color of the shadow drawn off of 'centerViewController` when a drawer is open.
By default, this is set to the systme default (opaque black).
*/
@property (nonatomic, strong) UIColor * shadowColor;
/**
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.
By default, this is set to NO.
*/
@property (nonatomic, assign) BOOL showsStatusBarBackgroundView;
/**
The color of the status bar background view if `showsStatusBarBackgroundView` is set to YES.
By default, this is set `[UIColor blackColor]`.
*/
@property (nonatomic, strong) UIColor * statusBarViewBackgroundColor;
/**
The value determining panning range of centerView's bezel if the user can open drawer with 'MMOpenDrawerGestureModeBezelPanningCenterView' or close drawer with 'MMCloseDrawerGestureModeBezelPanningCenterView' .
By default, this is set 20.0f.
*/
@property (nonatomic, assign) CGFloat bezelPanningCenterViewRange;
/**
The value determining if the user can open or close drawer with panGesture velocity.
By default, this is set 200.0f.
*/
@property (nonatomic, assign) CGFloat panVelocityXAnimationThreshold;
///---------------------------------------
/// @name Initializing a `MMDrawerController`
///---------------------------------------
/**
Creates and initializes an `MMDrawerController` object with the specified center view controller, left drawer view controller, and right drawer view controller.
@param centerViewController The center view controller. This argument must not be `nil`.
@param leftDrawerViewController The left drawer view controller.
@param rightDrawerViewController The right drawer controller.
@return The newly-initialized drawer container view controller.
*/
-(instancetype)initWithCenterViewController:(UIViewController *)centerViewController leftDrawerViewController:(UIViewController *)leftDrawerViewController rightDrawerViewController:(UIViewController *)rightDrawerViewController;
/**
Creates and initializes an `MMDrawerController` object with the specified center view controller, left drawer view controller.
@param centerViewController The center view controller. This argument must not be `nil`.
@param leftDrawerViewController The left drawer view controller.
@return The newly-initialized drawer container view controller.
*/
-(instancetype)initWithCenterViewController:(UIViewController *)centerViewController leftDrawerViewController:(UIViewController *)leftDrawerViewController;
/**
Creates and initializes an `MMDrawerController` object with the specified center view controller, right drawer view controller.
@param centerViewController The center view controller. This argument must not be `nil`.
@param rightDrawerViewController The right drawer controller.
@return The newly-initialized drawer container view controller.
*/
-(instancetype)initWithCenterViewController:(UIViewController *)centerViewController rightDrawerViewController:(UIViewController *)rightDrawerViewController;
///---------------------------------------
/// @name Opening and Closing a Drawer
///---------------------------------------
/**
Toggles the drawer open/closed based on the `drawer` passed in.
Note that if you attempt to toggle a drawer closed while the other is open, nothing will happen. For example, if you pass in MMDrawerSideLeft, but the right drawer is open, nothing will happen. In addition, the completion block will be called with the finished flag set to NO.
@param drawerSide The `MMDrawerSide` to toggle. This value cannot be `MMDrawerSideNone`.
@param animated Determines whether the `drawer` should be toggle animated.
@param completion The block that is called when the toggle is complete, or if no toggle took place at all.
*/
-(void)toggleDrawerSide:(MMDrawerSide)drawerSide animated:(BOOL)animated completion:(void(^)(BOOL finished))completion;
/**
Closes the open drawer.
@param animated Determines whether the drawer side should be closed animated
@param completion The block that is called when the close is complete
*/
-(void)closeDrawerAnimated:(BOOL)animated completion:(void(^)(BOOL finished))completion;
/**
Opens the `drawer` passed in.
@param drawerSide The `MMDrawerSide` to open. This value cannot be `MMDrawerSideNone`.
@param animated Determines whether the `drawer` should be open animated.
@param completion The block that is called when the toggle is open.
*/
-(void)openDrawerSide:(MMDrawerSide)drawerSide animated:(BOOL)animated completion:(void(^)(BOOL finished))completion;
///---------------------------------------
/// @name Setting a new Center View Controller
///---------------------------------------
/**
Sets the new `centerViewController`.
This sets the view controller and will automatically adjust the frame based on the current state of the drawer controller. If `closeAnimated` is YES, it will immediately change the center view controller, and close the drawer from its current position.
@param centerViewController The new `centerViewController`.
@param closeAnimated Determines whether the drawer should be closed with an animation.
@param completion The block called when the animation is finsihed.
*/
-(void)setCenterViewController:(UIViewController *)centerViewController withCloseAnimation:(BOOL)closeAnimated completion:(void(^)(BOOL finished))completion;
/**
Sets the new `centerViewController`.
This sets the view controller and will automatically adjust the frame based on the current state of the drawer controller. If `closeFullAnimated` is YES, the current center view controller will animate off the screen, the new center view controller will then be set, followed by the drawer closing across the full width of the screen.
@param newCenterViewController The new `centerViewController`.
@param fullCloseAnimated Determines whether the drawer should be closed with an animation.
@param completion The block called when the animation is finsihed.
*/
-(void)setCenterViewController:(UIViewController *)newCenterViewController withFullCloseAnimation:(BOOL)fullCloseAnimated completion:(void(^)(BOOL finished))completion;
///---------------------------------------
/// @name Animating the Width of a Drawer
///---------------------------------------
/**
Sets the maximum width of the left drawer view controller.
If the drawer is open, and `animated` is YES, it will animate the drawer frame as well as adjust the center view controller. If the drawer is not open, this change will take place immediately.
@param width The new width of left drawer view controller. This must be greater than zero.
@param animated Determines whether the drawer should be adjusted with an animation.
@param completion The block called when the animation is finished.
*/
-(void)setMaximumLeftDrawerWidth:(CGFloat)width animated:(BOOL)animated completion:(void(^)(BOOL finished))completion;
/**
Sets the maximum width of the right drawer view controller.
If the drawer is open, and `animated` is YES, it will animate the drawer frame as well as adjust the center view controller. If the drawer is not open, this change will take place immediately.
@param width The new width of right drawer view controller. This must be greater than zero.
@param animated Determines whether the drawer should be adjusted with an animation.
@param completion The block called when the animation is finished.
*/
-(void)setMaximumRightDrawerWidth:(CGFloat)width animated:(BOOL)animated completion:(void(^)(BOOL finished))completion;
///---------------------------------------
/// @name Previewing a Drawer
///---------------------------------------
/**
Bounce preview for the specified `drawerSide` a distance of 40 points.
@param drawerSide The drawer to preview. This value cannot be `MMDrawerSideNone`.
@param completion The block called when the animation is finsihed.
*/
-(void)bouncePreviewForDrawerSide:(MMDrawerSide)drawerSide completion:(void(^)(BOOL finished))completion;
/**
Bounce preview for the specified `drawerSide`.
@param drawerSide The drawer side to preview. This value cannot be `MMDrawerSideNone`.
@param distance The distance to bounce.
@param completion The block called when the animation is finsihed.
*/
-(void)bouncePreviewForDrawerSide:(MMDrawerSide)drawerSide distance:(CGFloat)distance completion:(void(^)(BOOL finished))completion;
///---------------------------------------
/// @name Custom Drawer Animations
///---------------------------------------
/**
Sets a callback to be called when a drawer visual state needs to be updated.
This block is responsible for updating the drawer's view state, and the drawer controller will handle animating to that state from the current state. This block will be called when the drawer is opened or closed, as well when the user is panning the drawer. This block is not responsible for doing animations directly, but instead just updating the state of the properies (such as alpha, anchor point, transform, etc). Note that if `shouldStretchDrawer` is set to YES, it is possible for `percentVisible` to be greater than 1.0. If `shouldStretchDrawer` is set to NO, `percentVisible` will never be greater than 1.0.
Note that when the drawer is finished opening or closing, the side drawer controller view will be reset with the following properies:
- alpha: 1.0
- transform: CATransform3DIdentity
- anchorPoint: (0.5,0.5)
@param drawerVisualStateBlock A block object to be called that allows the implementer to update visual state properties on the drawer. `percentVisible` represents the amount of the drawer space that is current visible, with drawer space being defined as the edge of the screen to the maxmimum drawer width. Note that you do have access to the drawerController, which will allow you to update things like the anchor point of the side drawer layer.
*/
-(void)setDrawerVisualStateBlock:(void(^)(MMDrawerController * drawerController, MMDrawerSide drawerSide, CGFloat percentVisible))drawerVisualStateBlock;
///---------------------------------------
/// @name Gesture Completion Handling
///---------------------------------------
/**
Sets a callback to be called when a gesture has been completed.
This block is called when a gesture action has been completed. You can query the `openSide` of the `drawerController` to determine what the new state of the drawer is.
@param gestureCompletionBlock A block object to be called that allows the implementer be notified when a gesture action has been completed.
*/
-(void)setGestureCompletionBlock:(void(^)(MMDrawerController * drawerController, UIGestureRecognizer * gesture))gestureCompletionBlock;
///---------------------------------------
/// @name Custom Gesture Handler
///---------------------------------------
/**
Sets a callback to be called to determine if a UIGestureRecognizer should recieve the given UITouch.
This block provides a way to allow a gesture to be recognized with custom logic. For example, you may have a certain part of your view that should accept a pan gesture recognizer to open the drawer, but not another a part. If you return YES, the gesture is recognized and the appropriate action is taken. This provides similar support to how Facebook allows you to pan on the background view of the main table view, but not the content itself. You can inspect the `openSide` property of the `drawerController` to determine the current state of the drawer, and apply the appropriate logic within your block.
Note that either `openDrawerGestureModeMask` must contain `MMOpenDrawerGestureModeCustom`, or `closeDrawerGestureModeMask` must contain `MMCloseDrawerGestureModeCustom` for this block to be consulted.
@param gestureShouldRecognizeTouchBlock A block object to be called to determine if the given `touch` should be recognized by the given gesture.
*/
-(void)setGestureShouldRecognizeTouchBlock:(BOOL(^)(MMDrawerController * drawerController, UIGestureRecognizer * gesture, UITouch * touch))gestureShouldRecognizeTouchBlock;
@end
================================================
FILE: MMDrawerController/MMDrawerController.m
================================================
// Copyright (c) 2013 Mutual Mobile (http://mutualmobile.com/)
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
#import "MMDrawerController.h"
#import "UIViewController+MMDrawerController.h"
#import
CGFloat const MMDrawerDefaultWidth = 280.0f;
CGFloat const MMDrawerDefaultAnimationVelocity = 840.0f;
NSTimeInterval const MMDrawerDefaultFullAnimationDelay = 0.10f;
CGFloat const MMDrawerDefaultBounceDistance = 50.0f;
NSTimeInterval const MMDrawerDefaultBounceAnimationDuration = 0.2f;
CGFloat const MMDrawerDefaultSecondBounceDistancePercentage = .25f;
CGFloat const MMDrawerDefaultShadowRadius = 10.0f;
CGFloat const MMDrawerDefaultShadowOpacity = 0.8;
NSTimeInterval const MMDrawerMinimumAnimationDuration = 0.15f;
CGFloat const MMDrawerBezelRange = 20.0f;
CGFloat const MMDrawerPanVelocityXAnimationThreshold = 200.0f;
/** The amount of overshoot that is panned linearly. The remaining percentage nonlinearly asymptotes to the max percentage. */
CGFloat const MMDrawerOvershootLinearRangePercentage = 0.75f;
/** The percent of the possible overshoot width to use as the actual overshoot percentage. */
CGFloat const MMDrawerOvershootPercentage = 0.1f;
typedef BOOL (^MMDrawerGestureShouldRecognizeTouchBlock)(MMDrawerController * drawerController, UIGestureRecognizer * gesture, UITouch * touch);
typedef void (^MMDrawerGestureCompletionBlock)(MMDrawerController * drawerController, UIGestureRecognizer * gesture);
static CAKeyframeAnimation * bounceKeyFrameAnimationForDistanceOnView(CGFloat distance, UIView * view) {
CGFloat factors[32] = {0, 32, 60, 83, 100, 114, 124, 128, 128, 124, 114, 100, 83, 60, 32,
0, 24, 42, 54, 62, 64, 62, 54, 42, 24, 0, 18, 28, 32, 28, 18, 0};
NSMutableArray *values = [NSMutableArray array];
for (int i=0; i<32; i++)
{
CGFloat positionOffset = factors[i]/128.0f * distance + CGRectGetMidX(view.bounds);
[values addObject:@(positionOffset)];
}
CAKeyframeAnimation *animation = [CAKeyframeAnimation animationWithKeyPath:@"position.x"];
animation.repeatCount = 1;
animation.duration = .8;
animation.fillMode = kCAFillModeForwards;
animation.values = values;
animation.removedOnCompletion = YES;
animation.autoreverses = NO;
return animation;
}
static NSString *MMDrawerLeftDrawerKey = @"MMDrawerLeftDrawer";
static NSString *MMDrawerRightDrawerKey = @"MMDrawerRightDrawer";
static NSString *MMDrawerCenterKey = @"MMDrawerCenter";
static NSString *MMDrawerOpenSideKey = @"MMDrawerOpenSide";
@interface MMDrawerCenterContainerView : UIView
@property (nonatomic,assign) MMDrawerOpenCenterInteractionMode centerInteractionMode;
@property (nonatomic,assign) MMDrawerSide openSide;
@end
@implementation MMDrawerCenterContainerView
-(UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event{
UIView *hitView = [super hitTest:point withEvent:event];
if(hitView &&
self.openSide != MMDrawerSideNone){
UINavigationBar * navBar = [self navigationBarContainedWithinSubviewsOfView:self];
CGRect navBarFrame = [navBar convertRect:navBar.bounds toView:self];
if((self.centerInteractionMode == MMDrawerOpenCenterInteractionModeNavigationBarOnly &&
CGRectContainsPoint(navBarFrame, point) == NO) ||
self.centerInteractionMode == MMDrawerOpenCenterInteractionModeNone){
hitView = nil;
}
}
return hitView;
}
-(UINavigationBar*)navigationBarContainedWithinSubviewsOfView:(UIView*)view{
UINavigationBar * navBar = nil;
for(UIView * subview in [view subviews]){
if([view isKindOfClass:[UINavigationBar class]]){
navBar = (UINavigationBar*)view;
break;
}
else {
navBar = [self navigationBarContainedWithinSubviewsOfView:subview];
if (navBar != nil) {
break;
}
}
}
return navBar;
}
@end
@interface MMDrawerController () {
CGFloat _maximumRightDrawerWidth;
CGFloat _maximumLeftDrawerWidth;
UIColor * _statusBarViewBackgroundColor;
}
@property (nonatomic, assign, readwrite) MMDrawerSide openSide;
@property (nonatomic, strong) UIView * childControllerContainerView;
@property (nonatomic, strong) MMDrawerCenterContainerView * centerContainerView;
@property (nonatomic, strong) UIView * dummyStatusBarView;
@property (nonatomic, assign) CGRect startingPanRect;
@property (nonatomic, copy) MMDrawerControllerDrawerVisualStateBlock drawerVisualState;
@property (nonatomic, copy) MMDrawerGestureShouldRecognizeTouchBlock gestureShouldRecognizeTouch;
@property (nonatomic, copy) MMDrawerGestureCompletionBlock gestureCompletion;
@property (nonatomic, assign, getter = isAnimatingDrawer) BOOL animatingDrawer;
@end
@implementation MMDrawerController
#pragma mark - Init
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
[self commonSetup];
}
return self;
}
- (id)initWithCoder:(NSCoder *)aDecoder{
self = [super initWithCoder:aDecoder];
if (self) {
[self commonSetup];
}
return self;
}
-(instancetype)initWithCenterViewController:(UIViewController *)centerViewController leftDrawerViewController:(UIViewController *)leftDrawerViewController rightDrawerViewController:(UIViewController *)rightDrawerViewController{
NSParameterAssert(centerViewController);
self = [super init];
if(self){
[self setCenterViewController:centerViewController];
[self setLeftDrawerViewController:leftDrawerViewController];
[self setRightDrawerViewController:rightDrawerViewController];
}
return self;
}
-(instancetype)initWithCenterViewController:(UIViewController *)centerViewController leftDrawerViewController:(UIViewController *)leftDrawerViewController{
return [self initWithCenterViewController:centerViewController leftDrawerViewController:leftDrawerViewController rightDrawerViewController:nil];
}
-(instancetype)initWithCenterViewController:(UIViewController *)centerViewController rightDrawerViewController:(UIViewController *)rightDrawerViewController{
return [self initWithCenterViewController:centerViewController leftDrawerViewController:nil rightDrawerViewController:rightDrawerViewController];
}
-(void)commonSetup{
[self setMaximumLeftDrawerWidth:MMDrawerDefaultWidth];
[self setMaximumRightDrawerWidth:MMDrawerDefaultWidth];
[self setAnimationVelocity:MMDrawerDefaultAnimationVelocity];
[self setShowsShadow:YES];
[self setShouldStretchDrawer:YES];
[self setOpenDrawerGestureModeMask:MMOpenDrawerGestureModeNone];
[self setCloseDrawerGestureModeMask:MMCloseDrawerGestureModeNone];
[self setCenterHiddenInteractionMode:MMDrawerOpenCenterInteractionModeNavigationBarOnly];
// set shadow related default values
[self setShadowOpacity:MMDrawerDefaultShadowOpacity];
[self setShadowRadius:MMDrawerDefaultShadowRadius];
[self setShadowOffset:CGSizeMake(0, -3)];
[self setShadowColor:[UIColor blackColor]];
// set default bezel range for panGestureReconizer
[self setBezelPanningCenterViewRange:MMDrawerBezelRange];
// set defualt panVelocityXAnimationThreshold
[self setPanVelocityXAnimationThreshold:MMDrawerPanVelocityXAnimationThreshold];
}
#pragma mark - State Restoration
- (void)encodeRestorableStateWithCoder:(NSCoder *)coder{
[super encodeRestorableStateWithCoder:coder];
if (self.leftDrawerViewController){
[coder encodeObject:self.leftDrawerViewController forKey:MMDrawerLeftDrawerKey];
}
if (self.rightDrawerViewController){
[coder encodeObject:self.rightDrawerViewController forKey:MMDrawerRightDrawerKey];
}
if (self.centerViewController){
[coder encodeObject:self.centerViewController forKey:MMDrawerCenterKey];
}
[coder encodeInteger:self.openSide forKey:MMDrawerOpenSideKey];
}
- (void)decodeRestorableStateWithCoder:(NSCoder *)coder{
UIViewController *controller;
MMDrawerSide openside;
[super decodeRestorableStateWithCoder:coder];
if ((controller = [coder decodeObjectForKey:MMDrawerLeftDrawerKey])){
self.leftDrawerViewController = controller;
}
if ((controller = [coder decodeObjectForKey:MMDrawerRightDrawerKey])){
self.rightDrawerViewController = controller;
}
if ((controller = [coder decodeObjectForKey:MMDrawerCenterKey])){
self.centerViewController = controller;
}
if ((openside = [coder decodeIntegerForKey:MMDrawerOpenSideKey])){
[self openDrawerSide:openside animated:false completion:nil];
}
}
#pragma mark - Open/Close methods
-(void)toggleDrawerSide:(MMDrawerSide)drawerSide animated:(BOOL)animated completion:(void (^)(BOOL finished))completion{
NSParameterAssert(drawerSide!=MMDrawerSideNone);
if(self.openSide == MMDrawerSideNone){
[self openDrawerSide:drawerSide animated:animated completion:completion];
}
else {
if((drawerSide == MMDrawerSideLeft &&
self.openSide == MMDrawerSideLeft) ||
(drawerSide == MMDrawerSideRight &&
self.openSide == MMDrawerSideRight)){
[self closeDrawerAnimated:animated completion:completion];
}
else if(completion){
completion(NO);
}
}
}
-(void)closeDrawerAnimated:(BOOL)animated completion:(void (^)(BOOL finished))completion{
[self closeDrawerAnimated:animated velocity:self.animationVelocity animationOptions:UIViewAnimationOptionCurveEaseInOut completion:completion];
}
-(void)closeDrawerAnimated:(BOOL)animated velocity:(CGFloat)velocity animationOptions:(UIViewAnimationOptions)options completion:(void (^)(BOOL finished))completion{
if(self.isAnimatingDrawer){
if(completion){
completion(NO);
}
}
else {
[self setAnimatingDrawer:animated];
CGRect newFrame = self.childControllerContainerView.bounds;
CGFloat distance = ABS(CGRectGetMinX(self.centerContainerView.frame));
NSTimeInterval duration = MAX(distance/ABS(velocity),MMDrawerMinimumAnimationDuration);
BOOL leftDrawerVisible = CGRectGetMinX(self.centerContainerView.frame) > 0;
BOOL rightDrawerVisible = CGRectGetMinX(self.centerContainerView.frame) < 0;
MMDrawerSide visibleSide = MMDrawerSideNone;
CGFloat percentVisble = 0.0;
if(leftDrawerVisible){
CGFloat visibleDrawerPoints = CGRectGetMinX(self.centerContainerView.frame);
percentVisble = MAX(0.0,visibleDrawerPoints/self.maximumLeftDrawerWidth);
visibleSide = MMDrawerSideLeft;
}
else if(rightDrawerVisible){
CGFloat visibleDrawerPoints = CGRectGetWidth(self.centerContainerView.frame)-CGRectGetMaxX(self.centerContainerView.frame);
percentVisble = MAX(0.0,visibleDrawerPoints/self.maximumRightDrawerWidth);
visibleSide = MMDrawerSideRight;
}
UIViewController * sideDrawerViewController = [self sideDrawerViewControllerForSide:visibleSide];
[self updateDrawerVisualStateForDrawerSide:visibleSide percentVisible:percentVisble];
[sideDrawerViewController beginAppearanceTransition:NO animated:animated];
[UIView
animateWithDuration:(animated?duration:0.0)
delay:0.0
options:options
animations:^{
[self setNeedsStatusBarAppearanceUpdateIfSupported];
[self.centerContainerView setFrame:newFrame];
[self updateDrawerVisualStateForDrawerSide:visibleSide percentVisible:0.0];
}
completion:^(BOOL finished) {
[sideDrawerViewController endAppearanceTransition];
[self setOpenSide:MMDrawerSideNone];
[self resetDrawerVisualStateForDrawerSide:visibleSide];
[self setAnimatingDrawer:NO];
if(completion){
completion(finished);
}
}];
}
}
-(void)openDrawerSide:(MMDrawerSide)drawerSide animated:(BOOL)animated completion:(void (^)(BOOL finished))completion{
NSParameterAssert(drawerSide != MMDrawerSideNone);
[self openDrawerSide:drawerSide animated:animated velocity:self.animationVelocity animationOptions:UIViewAnimationOptionCurveEaseInOut completion:completion];
}
-(void)openDrawerSide:(MMDrawerSide)drawerSide animated:(BOOL)animated velocity:(CGFloat)velocity animationOptions:(UIViewAnimationOptions)options completion:(void (^)(BOOL finished))completion{
NSParameterAssert(drawerSide != MMDrawerSideNone);
if (self.isAnimatingDrawer) {
if(completion){
completion(NO);
}
}
else {
[self setAnimatingDrawer:animated];
UIViewController * sideDrawerViewController = [self sideDrawerViewControllerForSide:drawerSide];
if (self.openSide != drawerSide) {
[self prepareToPresentDrawer:drawerSide animated:animated];
}
if(sideDrawerViewController){
CGRect newFrame;
CGRect oldFrame = self.centerContainerView.frame;
if(drawerSide == MMDrawerSideLeft){
newFrame = self.centerContainerView.frame;
newFrame.origin.x = self.maximumLeftDrawerWidth;
}
else {
newFrame = self.centerContainerView.frame;
newFrame.origin.x = 0-self.maximumRightDrawerWidth;
}
CGFloat distance = ABS(CGRectGetMinX(oldFrame)-newFrame.origin.x);
NSTimeInterval duration = MAX(distance/ABS(velocity),MMDrawerMinimumAnimationDuration);
[UIView
animateWithDuration:(animated?duration:0.0)
delay:0.0
options:options
animations:^{
[self setNeedsStatusBarAppearanceUpdateIfSupported];
[self.centerContainerView setFrame:newFrame];
[self updateDrawerVisualStateForDrawerSide:drawerSide percentVisible:1.0];
}
completion:^(BOOL finished) {
//End the appearance transition if it already wasn't open.
if(drawerSide != self.openSide){
[sideDrawerViewController endAppearanceTransition];
}
[self setOpenSide:drawerSide];
[self resetDrawerVisualStateForDrawerSide:drawerSide];
[self setAnimatingDrawer:NO];
if(completion){
completion(finished);
}
}];
}
}
}
#pragma mark - Updating the Center View Controller
//If animated is NO, then we need to handle all the appearance calls within this method. Otherwise,
//let the method calling this one handle proper appearance methods since they will have more context
-(void)setCenterViewController:(UIViewController *)centerViewController animated:(BOOL)animated{
if ([self.centerViewController isEqual:centerViewController]) {
return;
}
if (_centerContainerView == nil) {
//This is related to Issue #152 (https://github.com/mutualmobile/MMDrawerController/issues/152)
// also fixed below in the getter for `childControllerContainerView`. Turns out we have
// two center container views getting added to the view during init,
// because the first request self.centerContainerView.bounds was kicking off a
// viewDidLoad, which caused us to be able to fall through this check twice.
//
//The fix is to grab the bounds, and then check again that the child container view has
//not been created.
CGRect centerFrame = self.childControllerContainerView.bounds;
if(_centerContainerView == nil){
_centerContainerView = [[MMDrawerCenterContainerView alloc] initWithFrame:centerFrame];
[self.centerContainerView setAutoresizingMask:UIViewAutoresizingFlexibleWidth|UIViewAutoresizingFlexibleHeight];
[self.centerContainerView setBackgroundColor:[UIColor clearColor]];
[self.centerContainerView setOpenSide:self.openSide];
[self.centerContainerView setCenterInteractionMode:self.centerHiddenInteractionMode];
[self.childControllerContainerView addSubview:self.centerContainerView];
}
}
UIViewController * oldCenterViewController = self.centerViewController;
if(oldCenterViewController){
[oldCenterViewController willMoveToParentViewController:nil];
if(animated == NO){
[oldCenterViewController beginAppearanceTransition:NO animated:NO];
}
[oldCenterViewController.view removeFromSuperview];
if(animated == NO){
[oldCenterViewController endAppearanceTransition];
}
[oldCenterViewController removeFromParentViewController];
}
_centerViewController = centerViewController;
[self addChildViewController:self.centerViewController];
[self.centerViewController.view setFrame:self.childControllerContainerView.bounds];
[self.centerContainerView addSubview:self.centerViewController.view];
[self.childControllerContainerView bringSubviewToFront:self.centerContainerView];
[self.centerViewController.view setAutoresizingMask:UIViewAutoresizingFlexibleWidth|UIViewAutoresizingFlexibleHeight];
[self updateShadowForCenterView];
if(animated == NO){
// If drawer is offscreen, then viewWillAppear: will take care of this
if(self.view.window) {
[self.centerViewController beginAppearanceTransition:YES animated:NO];
[self.centerViewController endAppearanceTransition];
}
[self.centerViewController didMoveToParentViewController:self];
}
}
-(void)setCenterViewController:(UIViewController *)newCenterViewController withCloseAnimation:(BOOL)animated completion:(void(^)(BOOL finished))completion{
if(self.openSide == MMDrawerSideNone){
//If a side drawer isn't open, there is nothing to animate...
animated = NO;
}
BOOL forwardAppearanceMethodsToCenterViewController = ([self.centerViewController isEqual:newCenterViewController] == NO);
UIViewController * oldCenterViewController = self.centerViewController;
// This is related to issue 363 (https://github.com/novkostya/MMDrawerController/pull/363)
// This needs to be refactored so the appearance logic is easier
// to follow across the multiple close/setter methods
if (animated && forwardAppearanceMethodsToCenterViewController) {
[oldCenterViewController beginAppearanceTransition:NO animated:NO];
}
[self setCenterViewController:newCenterViewController animated:animated];
// Related to note above.
if (animated && forwardAppearanceMethodsToCenterViewController) {
[oldCenterViewController endAppearanceTransition];
}
if(animated){
[self updateDrawerVisualStateForDrawerSide:self.openSide percentVisible:1.0];
if (forwardAppearanceMethodsToCenterViewController) {
[self.centerViewController beginAppearanceTransition:YES animated:animated];
}
[self
closeDrawerAnimated:animated
completion:^(BOOL finished) {
if (forwardAppearanceMethodsToCenterViewController) {
[self.centerViewController endAppearanceTransition];
[self.centerViewController didMoveToParentViewController:self];
}
if(completion){
completion(finished);
}
}];
}
else {
if(completion) {
completion(YES);
}
}
}
-(void)setCenterViewController:(UIViewController *)newCenterViewController withFullCloseAnimation:(BOOL)animated completion:(void(^)(BOOL finished))completion{
if(self.openSide != MMDrawerSideNone &&
animated){
BOOL forwardAppearanceMethodsToCenterViewController = ([self.centerViewController isEqual:newCenterViewController] == NO);
UIViewController * sideDrawerViewController = [self sideDrawerViewControllerForSide:self.openSide];
CGFloat targetClosePoint = 0.0f;
if(self.openSide == MMDrawerSideRight){
targetClosePoint = -CGRectGetWidth(self.childControllerContainerView.bounds);
}
else if(self.openSide == MMDrawerSideLeft) {
targetClosePoint = CGRectGetWidth(self.childControllerContainerView.bounds);
}
CGFloat distance = ABS(self.centerContainerView.frame.origin.x-targetClosePoint);
NSTimeInterval firstDuration = [self animationDurationForAnimationDistance:distance];
CGRect newCenterRect = self.centerContainerView.frame;
[self setAnimatingDrawer:animated];
UIViewController * oldCenterViewController = self.centerViewController;
if(forwardAppearanceMethodsToCenterViewController ){
[oldCenterViewController beginAppearanceTransition:NO animated:animated];
}
newCenterRect.origin.x = targetClosePoint;
[UIView
animateWithDuration:firstDuration
delay:0.0
options:UIViewAnimationOptionCurveEaseInOut
animations:^{
[self.centerContainerView setFrame:newCenterRect];
[sideDrawerViewController.view setFrame:self.childControllerContainerView.bounds];
}
completion:^(BOOL finished) {
CGRect oldCenterRect = self.centerContainerView.frame;
[self setCenterViewController:newCenterViewController animated:animated];
[self.centerContainerView setFrame:oldCenterRect];
[self updateDrawerVisualStateForDrawerSide:self.openSide percentVisible:1.0];
if(forwardAppearanceMethodsToCenterViewController) {
[oldCenterViewController endAppearanceTransition];
[self.centerViewController beginAppearanceTransition:YES animated:animated];
}
[sideDrawerViewController beginAppearanceTransition:NO animated:animated];
[UIView
animateWithDuration:[self animationDurationForAnimationDistance:CGRectGetWidth(self.childControllerContainerView.bounds)]
delay:MMDrawerDefaultFullAnimationDelay
options:UIViewAnimationOptionCurveEaseInOut
animations:^{
[self.centerContainerView setFrame:self.childControllerContainerView.bounds];
[self updateDrawerVisualStateForDrawerSide:self.openSide percentVisible:0.0];
}
completion:^(BOOL finished) {
if (forwardAppearanceMethodsToCenterViewController) {
[self.centerViewController endAppearanceTransition];
[self.centerViewController didMoveToParentViewController:self];
}
[sideDrawerViewController endAppearanceTransition];
[self resetDrawerVisualStateForDrawerSide:self.openSide];
[sideDrawerViewController.view setFrame:sideDrawerViewController.mm_visibleDrawerFrame];
[self setOpenSide:MMDrawerSideNone];
[self setAnimatingDrawer:NO];
if(completion){
completion(finished);
}
}];
}];
}
else {
[self setCenterViewController:newCenterViewController animated:animated];
if(self.openSide != MMDrawerSideNone){
[self closeDrawerAnimated:animated completion:completion];
}
else if(completion){
completion(YES);
}
}
}
#pragma mark - Size Methods
-(void)setMaximumLeftDrawerWidth:(CGFloat)width animated:(BOOL)animated completion:(void(^)(BOOL finished))completion{
[self setMaximumDrawerWidth:width forSide:MMDrawerSideLeft animated:animated completion:completion];
}
-(void)setMaximumRightDrawerWidth:(CGFloat)width animated:(BOOL)animated completion:(void(^)(BOOL finished))completion{
[self setMaximumDrawerWidth:width forSide:MMDrawerSideRight animated:animated completion:completion];
}
- (void)setMaximumDrawerWidth:(CGFloat)width forSide:(MMDrawerSide)drawerSide animated:(BOOL)animated completion:(void(^)(BOOL finished))completion{
NSParameterAssert(width > 0);
NSParameterAssert(drawerSide != MMDrawerSideNone);
UIViewController *sideDrawerViewController = [self sideDrawerViewControllerForSide:drawerSide];
CGFloat oldWidth = 0.f;
NSInteger drawerSideOriginCorrection = 1;
if (drawerSide == MMDrawerSideLeft) {
oldWidth = _maximumLeftDrawerWidth;
_maximumLeftDrawerWidth = width;
}
else if(drawerSide == MMDrawerSideRight){
oldWidth = _maximumRightDrawerWidth;
_maximumRightDrawerWidth = width;
drawerSideOriginCorrection = -1;
}
CGFloat distance = ABS(width-oldWidth);
NSTimeInterval duration = [self animationDurationForAnimationDistance:distance];
if(self.openSide == drawerSide){
CGRect newCenterRect = self.centerContainerView.frame;
newCenterRect.origin.x = drawerSideOriginCorrection*width;
[UIView
animateWithDuration:(animated?duration:0)
delay:0.0
options:UIViewAnimationOptionCurveEaseInOut
animations:^{
[self.centerContainerView setFrame:newCenterRect];
[sideDrawerViewController.view setFrame:sideDrawerViewController.mm_visibleDrawerFrame];
}
completion:^(BOOL finished) {
if(completion != nil){
completion(finished);
}
}];
}
else{
[sideDrawerViewController.view setFrame:sideDrawerViewController.mm_visibleDrawerFrame];
if(completion != nil){
completion(YES);
}
}
}
#pragma mark - Bounce Methods
-(void)bouncePreviewForDrawerSide:(MMDrawerSide)drawerSide completion:(void(^)(BOOL finished))completion{
NSParameterAssert(drawerSide!=MMDrawerSideNone);
[self bouncePreviewForDrawerSide:drawerSide distance:MMDrawerDefaultBounceDistance completion:completion];
}
-(void)bouncePreviewForDrawerSide:(MMDrawerSide)drawerSide distance:(CGFloat)distance completion:(void(^)(BOOL finished))completion{
NSParameterAssert(drawerSide!=MMDrawerSideNone);
UIViewController * sideDrawerViewController = [self sideDrawerViewControllerForSide:drawerSide];
if(sideDrawerViewController == nil ||
self.openSide != MMDrawerSideNone){
if(completion){
completion(NO);
}
return;
}
else {
[self prepareToPresentDrawer:drawerSide animated:YES];
[self updateDrawerVisualStateForDrawerSide:drawerSide percentVisible:1.0];
[CATransaction begin];
[CATransaction
setCompletionBlock:^{
[sideDrawerViewController endAppearanceTransition];
[sideDrawerViewController beginAppearanceTransition:NO animated:NO];
[sideDrawerViewController endAppearanceTransition];
if(completion){
completion(YES);
}
}];
CGFloat modifier = ((drawerSide == MMDrawerSideLeft)?1.0:-1.0);
CAKeyframeAnimation *animation = bounceKeyFrameAnimationForDistanceOnView(distance*modifier,self.centerContainerView);
[self.centerContainerView.layer addAnimation:animation forKey:@"bouncing"];
[CATransaction commit];
}
}
#pragma mark - Setting Drawer Visual State
-(void)setDrawerVisualStateBlock:(void (^)(MMDrawerController *, MMDrawerSide, CGFloat))drawerVisualStateBlock{
[self setDrawerVisualState:drawerVisualStateBlock];
}
#pragma mark - Setting Custom Gesture Handler Block
-(void)setGestureShouldRecognizeTouchBlock:(BOOL (^)(MMDrawerController *, UIGestureRecognizer *, UITouch *))gestureShouldRecognizeTouchBlock{
[self setGestureShouldRecognizeTouch:gestureShouldRecognizeTouchBlock];
}
#pragma mark - Setting the Gesture Completion Block
-(void)setGestureCompletionBlock:(void (^)(MMDrawerController *, UIGestureRecognizer *))gestureCompletionBlock{
[self setGestureCompletion:gestureCompletionBlock];
}
#pragma mark - Subclass Methods
-(BOOL)shouldAutomaticallyForwardAppearanceMethods{
return NO;
}
-(BOOL)shouldAutomaticallyForwardRotationMethods{
return NO;
}
-(BOOL)automaticallyForwardAppearanceAndRotationMethodsToChildViewControllers{
return NO;
}
#pragma mark - View Lifecycle
- (void)viewDidLoad {
[super viewDidLoad];
[self.view setBackgroundColor:[UIColor blackColor]];
[self setupGestureRecognizers];
}
-(void)viewWillAppear:(BOOL)animated{
[super viewWillAppear:animated];
[self.centerViewController beginAppearanceTransition:YES animated:animated];
if(self.openSide == MMDrawerSideLeft) {
[self.leftDrawerViewController beginAppearanceTransition:YES animated:animated];
}
else if(self.openSide == MMDrawerSideRight) {
[self.rightDrawerViewController beginAppearanceTransition:YES animated:animated];
}
}
-(void)viewDidAppear:(BOOL)animated{
[super viewDidAppear:animated];
[self updateShadowForCenterView];
[self.centerViewController endAppearanceTransition];
if(self.openSide == MMDrawerSideLeft) {
[self.leftDrawerViewController endAppearanceTransition];
}
else if(self.openSide == MMDrawerSideRight) {
[self.rightDrawerViewController endAppearanceTransition];
}
}
-(void)viewWillDisappear:(BOOL)animated{
[super viewWillDisappear:animated];
[self.centerViewController beginAppearanceTransition:NO animated:animated];
if(self.openSide == MMDrawerSideLeft) {
[self.leftDrawerViewController beginAppearanceTransition:NO animated:animated];
}
else if (self.openSide == MMDrawerSideRight) {
[self.rightDrawerViewController beginAppearanceTransition:NO animated:animated];
}
}
-(void)viewDidDisappear:(BOOL)animated{
[super viewDidDisappear:animated];
[self.centerViewController endAppearanceTransition];
if(self.openSide == MMDrawerSideLeft) {
[self.leftDrawerViewController endAppearanceTransition];
}
else if (self.openSide == MMDrawerSideRight) {
[self.rightDrawerViewController endAppearanceTransition];
}
}
#pragma mark Rotation
-(void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration{
[super willRotateToInterfaceOrientation:toInterfaceOrientation duration:duration];
//If a rotation begins, we are going to cancel the current gesture and reset transform and anchor points so everything works correctly
BOOL gestureInProgress = NO;
for(UIGestureRecognizer * gesture in self.view.gestureRecognizers){
if(gesture.state == UIGestureRecognizerStateChanged){
[gesture setEnabled:NO];
[gesture setEnabled:YES];
gestureInProgress = YES;
}
if (gestureInProgress) {
[self resetDrawerVisualStateForDrawerSide:self.openSide];
}
}
if ([self needsManualForwardingOfRotationEvents]){
for(UIViewController * childViewController in self.childViewControllers){
[childViewController willRotateToInterfaceOrientation:toInterfaceOrientation duration:duration];
}
}
}
-(void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration{
[super willAnimateRotationToInterfaceOrientation:toInterfaceOrientation duration:duration];
//We need to support the shadow path rotation animation
//Inspired from here: http://blog.radi.ws/post/8348898129/calayers-shadowpath-and-uiview-autoresizing
if(self.showsShadow){
CGPathRef oldShadowPath = self.centerContainerView.layer.shadowPath;
if(oldShadowPath){
CFRetain(oldShadowPath);
}
[self updateShadowForCenterView];
if (oldShadowPath) {
[self.centerContainerView.layer addAnimation:((^ {
CABasicAnimation *transition = [CABasicAnimation animationWithKeyPath:@"shadowPath"];
transition.fromValue = (__bridge id)oldShadowPath;
transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
transition.duration = duration;
return transition;
})()) forKey:@"transition"];
CFRelease(oldShadowPath);
}
}
if ([self needsManualForwardingOfRotationEvents]){
for(UIViewController * childViewController in self.childViewControllers){
[childViewController willAnimateRotationToInterfaceOrientation:toInterfaceOrientation duration:duration];
}
}
}
-(BOOL)shouldAutorotate{
return YES;
}
-(void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation{
[super didRotateFromInterfaceOrientation:fromInterfaceOrientation];
if ([self needsManualForwardingOfRotationEvents]){
for(UIViewController * childViewController in self.childViewControllers){
[childViewController didRotateFromInterfaceOrientation:fromInterfaceOrientation];
}
}
}
#pragma mark - Setters
-(void)setRightDrawerViewController:(UIViewController *)rightDrawerViewController{
[self setDrawerViewController:rightDrawerViewController forSide:MMDrawerSideRight];
}
-(void)setLeftDrawerViewController:(UIViewController *)leftDrawerViewController{
[self setDrawerViewController:leftDrawerViewController forSide:MMDrawerSideLeft];
}
- (void)setDrawerViewController:(UIViewController *)viewController forSide:(MMDrawerSide)drawerSide{
NSParameterAssert(drawerSide != MMDrawerSideNone);
UIViewController *currentSideViewController = [self sideDrawerViewControllerForSide:drawerSide];
if (currentSideViewController == viewController) {
return;
}
if (currentSideViewController != nil) {
[currentSideViewController beginAppearanceTransition:NO animated:NO];
[currentSideViewController.view removeFromSuperview];
[currentSideViewController endAppearanceTransition];
[currentSideViewController willMoveToParentViewController:nil];
[currentSideViewController removeFromParentViewController];
}
UIViewAutoresizing autoResizingMask = 0;
if (drawerSide == MMDrawerSideLeft) {
_leftDrawerViewController = viewController;
autoResizingMask = UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleHeight;
}
else if(drawerSide == MMDrawerSideRight){
_rightDrawerViewController = viewController;
autoResizingMask = UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleHeight;
}
if(viewController){
[self addChildViewController:viewController];
if((self.openSide == drawerSide) &&
[self.childControllerContainerView.subviews containsObject:self.centerContainerView]){
[self.childControllerContainerView insertSubview:viewController.view belowSubview:self.centerContainerView];
[viewController beginAppearanceTransition:YES animated:NO];
[viewController endAppearanceTransition];
}
else{
[self.childControllerContainerView addSubview:viewController.view];
[self.childControllerContainerView sendSubviewToBack:viewController.view];
[viewController.view setHidden:YES];
}
[viewController didMoveToParentViewController:self];
[viewController.view setAutoresizingMask:autoResizingMask];
[viewController.view setFrame:viewController.mm_visibleDrawerFrame];
}
}
-(void)setCenterViewController:(UIViewController *)centerViewController{
[self setCenterViewController:centerViewController animated:NO];
}
-(void)setShowsShadow:(BOOL)showsShadow{
_showsShadow = showsShadow;
[self updateShadowForCenterView];
}
- (void)setShadowRadius:(CGFloat)shadowRadius{
_shadowRadius = shadowRadius;
[self updateShadowForCenterView];
}
- (void)setShadowOpacity:(CGFloat)shadowOpacity{
_shadowOpacity = shadowOpacity;
[self updateShadowForCenterView];
}
- (void)setShadowOffset:(CGSize)shadowOffset{
_shadowOffset = shadowOffset;
[self updateShadowForCenterView];
}
- (void)setShadowColor:(UIColor *)shadowColor{
_shadowColor = shadowColor;
[self updateShadowForCenterView];
}
-(void)setOpenSide:(MMDrawerSide)openSide{
if(_openSide != openSide){
_openSide = openSide;
[self.centerContainerView setOpenSide:openSide];
if(openSide == MMDrawerSideNone){
[self.leftDrawerViewController.view setHidden:YES];
[self.rightDrawerViewController.view setHidden:YES];
}
[self setNeedsStatusBarAppearanceUpdateIfSupported];
}
}
-(void)setCenterHiddenInteractionMode:(MMDrawerOpenCenterInteractionMode)centerHiddenInteractionMode{
if(_centerHiddenInteractionMode!=centerHiddenInteractionMode){
_centerHiddenInteractionMode = centerHiddenInteractionMode;
[self.centerContainerView setCenterInteractionMode:centerHiddenInteractionMode];
}
}
-(void)setMaximumLeftDrawerWidth:(CGFloat)maximumLeftDrawerWidth{
[self setMaximumLeftDrawerWidth:maximumLeftDrawerWidth animated:NO completion:nil];
}
-(void)setMaximumRightDrawerWidth:(CGFloat)maximumRightDrawerWidth{
[self setMaximumRightDrawerWidth:maximumRightDrawerWidth animated:NO completion:nil];
}
-(void)setShowsStatusBarBackgroundView:(BOOL)showsDummyStatusBar{
if(showsDummyStatusBar!=_showsStatusBarBackgroundView){
_showsStatusBarBackgroundView = showsDummyStatusBar;
CGRect frame = self.childControllerContainerView.frame;
if(_showsStatusBarBackgroundView){
frame.origin.y = 20;
frame.size.height = CGRectGetHeight(self.view.bounds)-20;
}
else {
frame.origin.y = 0;
frame.size.height = CGRectGetHeight(self.view.bounds);
}
[self.childControllerContainerView setFrame:frame];
[self.dummyStatusBarView setHidden:!showsDummyStatusBar];
}
}
-(void)setStatusBarViewBackgroundColor:(UIColor *)dummyStatusBarColor{
_statusBarViewBackgroundColor = dummyStatusBarColor;
[self.dummyStatusBarView setBackgroundColor:_statusBarViewBackgroundColor];
}
-(void)setAnimatingDrawer:(BOOL)animatingDrawer{
_animatingDrawer = animatingDrawer;
[self.view setUserInteractionEnabled:!animatingDrawer];
}
#pragma mark - Getters
-(CGFloat)maximumLeftDrawerWidth{
if(self.leftDrawerViewController){
return _maximumLeftDrawerWidth;
}
else{
return 0;
}
}
-(CGFloat)maximumRightDrawerWidth{
if(self.rightDrawerViewController){
return _maximumRightDrawerWidth;
}
else {
return 0;
}
}
-(CGFloat)visibleLeftDrawerWidth{
return MAX(0.0,CGRectGetMinX(self.centerContainerView.frame));
}
-(CGFloat)visibleRightDrawerWidth{
if(CGRectGetMinX(self.centerContainerView.frame)<0){
return CGRectGetWidth(self.childControllerContainerView.bounds)-CGRectGetMaxX(self.centerContainerView.frame);
}
else {
return 0.0f;
}
}
-(UIView*)childControllerContainerView{
if(_childControllerContainerView == nil){
//Issue #152 (https://github.com/mutualmobile/MMDrawerController/issues/152)
//Turns out we have two child container views getting added to the view during init,
//because the first request self.view.bounds was kicking off a viewDidLoad, which
//caused us to be able to fall through this check twice.
//
//The fix is to grab the bounds, and then check again that the child container view has
//not been created.
CGRect childContainerViewFrame = self.view.bounds;
if(_childControllerContainerView == nil){
_childControllerContainerView = [[UIView alloc] initWithFrame:childContainerViewFrame];
[_childControllerContainerView setBackgroundColor:[UIColor clearColor]];
[_childControllerContainerView setAutoresizingMask:UIViewAutoresizingFlexibleHeight|UIViewAutoresizingFlexibleWidth];
[self.view addSubview:_childControllerContainerView];
}
}
return _childControllerContainerView;
}
-(UIView*)dummyStatusBarView{
if(_dummyStatusBarView==nil){
_dummyStatusBarView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, CGRectGetWidth(self.view.bounds), 20)];
[_dummyStatusBarView setAutoresizingMask:UIViewAutoresizingFlexibleWidth];
[_dummyStatusBarView setBackgroundColor:self.statusBarViewBackgroundColor];
[_dummyStatusBarView setHidden:!_showsStatusBarBackgroundView];
[self.view addSubview:_dummyStatusBarView];
}
return _dummyStatusBarView;
}
-(UIColor*)statusBarViewBackgroundColor{
if(_statusBarViewBackgroundColor == nil){
_statusBarViewBackgroundColor = [UIColor blackColor];
}
return _statusBarViewBackgroundColor;
}
#pragma mark - Gesture Handlers
-(void)tapGestureCallback:(UITapGestureRecognizer *)tapGesture{
if(self.openSide != MMDrawerSideNone &&
self.isAnimatingDrawer == NO){
[self closeDrawerAnimated:YES completion:^(BOOL finished) {
if(self.gestureCompletion){
self.gestureCompletion(self, tapGesture);
}
}];
}
}
-(void)panGestureCallback:(UIPanGestureRecognizer *)panGesture{
switch (panGesture.state) {
case UIGestureRecognizerStateBegan:{
if(self.animatingDrawer){
[panGesture setEnabled:NO];
break;
}
else {
self.startingPanRect = self.centerContainerView.frame;
}
}
case UIGestureRecognizerStateChanged:{
self.view.userInteractionEnabled = NO;
CGRect newFrame = self.startingPanRect;
CGPoint translatedPoint = [panGesture translationInView:self.centerContainerView];
newFrame.origin.x = [self roundedOriginXForDrawerConstriants:CGRectGetMinX(self.startingPanRect)+translatedPoint.x];
newFrame = CGRectIntegral(newFrame);
CGFloat xOffset = newFrame.origin.x;
MMDrawerSide visibleSide = MMDrawerSideNone;
CGFloat percentVisible = 0.0;
if(xOffset > 0){
visibleSide = MMDrawerSideLeft;
percentVisible = xOffset/self.maximumLeftDrawerWidth;
}
else if(xOffset < 0){
visibleSide = MMDrawerSideRight;
percentVisible = ABS(xOffset)/self.maximumRightDrawerWidth;
}
UIViewController * visibleSideDrawerViewController = [self sideDrawerViewControllerForSide:visibleSide];
if(self.openSide != visibleSide){
//Handle disappearing the visible drawer
UIViewController * sideDrawerViewController = [self sideDrawerViewControllerForSide:self.openSide];
[sideDrawerViewController beginAppearanceTransition:NO animated:NO];
[sideDrawerViewController endAppearanceTransition];
//Drawer is about to become visible
[self prepareToPresentDrawer:visibleSide animated:NO];
[visibleSideDrawerViewController endAppearanceTransition];
[self setOpenSide:visibleSide];
}
else if(visibleSide == MMDrawerSideNone){
[self setOpenSide:MMDrawerSideNone];
}
[self updateDrawerVisualStateForDrawerSide:visibleSide percentVisible:percentVisible];
[self.centerContainerView setCenter:CGPointMake(CGRectGetMidX(newFrame), CGRectGetMidY(newFrame))];
newFrame = self.centerContainerView.frame;
newFrame.origin.x = floor(newFrame.origin.x);
newFrame.origin.y = floor(newFrame.origin.y);
self.centerContainerView.frame = newFrame;
break;
}
case UIGestureRecognizerStateEnded:
case UIGestureRecognizerStateCancelled: {
self.startingPanRect = CGRectNull;
CGPoint velocity = [panGesture velocityInView:self.childControllerContainerView];
[self finishAnimationForPanGestureWithXVelocity:velocity.x completion:^(BOOL finished) {
if(self.gestureCompletion){
self.gestureCompletion(self, panGesture);
}
}];
self.view.userInteractionEnabled = YES;
break;
}
default:
break;
}
}
#pragma mark - iOS 7 Status Bar Helpers
-(UIViewController*)childViewControllerForStatusBarStyle{
return [self childViewControllerForSide:self.openSide];
}
-(UIViewController*)childViewControllerForStatusBarHidden{
return [self childViewControllerForSide:self.openSide];
}
-(void)setNeedsStatusBarAppearanceUpdateIfSupported{
if([self respondsToSelector:@selector(setNeedsStatusBarAppearanceUpdate)]){
[self performSelector:@selector(setNeedsStatusBarAppearanceUpdate)];
}
}
#pragma mark - iOS 8 Rotation Helpers
- (BOOL)needsManualForwardingOfRotationEvents{
BOOL isIOS8 = (floor(NSFoundationVersionNumber) > NSFoundationVersionNumber_iOS_7_1);
return !isIOS8;
}
#pragma mark - Animation helpers
-(void)finishAnimationForPanGestureWithXVelocity:(CGFloat)xVelocity completion:(void(^)(BOOL finished))completion{
CGFloat currentOriginX = CGRectGetMinX(self.centerContainerView.frame);
CGFloat animationVelocity = MAX(ABS(xVelocity),self.panVelocityXAnimationThreshold*2);
if(self.openSide == MMDrawerSideLeft) {
CGFloat midPoint = self.maximumLeftDrawerWidth / 2.0;
if(xVelocity > self.panVelocityXAnimationThreshold){
[self openDrawerSide:MMDrawerSideLeft animated:YES velocity:animationVelocity animationOptions:UIViewAnimationOptionCurveEaseOut completion:completion];
}
else if(xVelocity < -self.panVelocityXAnimationThreshold){
[self closeDrawerAnimated:YES velocity:animationVelocity animationOptions:UIViewAnimationOptionCurveEaseOut completion:completion];
}
else if(currentOriginX < midPoint){
[self closeDrawerAnimated:YES completion:completion];
}
else {
[self openDrawerSide:MMDrawerSideLeft animated:YES completion:completion];
}
}
else if(self.openSide == MMDrawerSideRight){
currentOriginX = CGRectGetMaxX(self.centerContainerView.frame);
CGFloat midPoint = (CGRectGetWidth(self.childControllerContainerView.bounds)-self.maximumRightDrawerWidth) + (self.maximumRightDrawerWidth / 2.0);
if(xVelocity > self.panVelocityXAnimationThreshold){
[self closeDrawerAnimated:YES velocity:animationVelocity animationOptions:UIViewAnimationOptionCurveEaseOut completion:completion];
}
else if (xVelocity < -self.panVelocityXAnimationThreshold){
[self openDrawerSide:MMDrawerSideRight animated:YES velocity:animationVelocity animationOptions:UIViewAnimationOptionCurveEaseOut completion:completion];
}
else if(currentOriginX > midPoint){
[self closeDrawerAnimated:YES completion:completion];
}
else {
[self openDrawerSide:MMDrawerSideRight animated:YES completion:completion];
}
}
else {
if(completion){
completion(NO);
}
}
}
-(void)updateDrawerVisualStateForDrawerSide:(MMDrawerSide)drawerSide percentVisible:(CGFloat)percentVisible{
if(self.drawerVisualState){
self.drawerVisualState(self,drawerSide,percentVisible);
}
else if(self.shouldStretchDrawer){
[self applyOvershootScaleTransformForDrawerSide:drawerSide percentVisible:percentVisible];
}
}
- (void)applyOvershootScaleTransformForDrawerSide:(MMDrawerSide)drawerSide percentVisible:(CGFloat)percentVisible{
if (percentVisible >= 1.f) {
CATransform3D transform = CATransform3DIdentity;
UIViewController * sideDrawerViewController = [self sideDrawerViewControllerForSide:drawerSide];
if(drawerSide == MMDrawerSideLeft) {
transform = CATransform3DMakeScale(percentVisible, 1.f, 1.f);
transform = CATransform3DTranslate(transform, self.maximumLeftDrawerWidth*(percentVisible-1.f)/2, 0.f, 0.f);
}
else if(drawerSide == MMDrawerSideRight){
transform = CATransform3DMakeScale(percentVisible, 1.f, 1.f);
transform = CATransform3DTranslate(transform, -self.maximumRightDrawerWidth*(percentVisible-1.f)/2, 0.f, 0.f);
}
sideDrawerViewController.view.layer.transform = transform;
}
}
-(void)resetDrawerVisualStateForDrawerSide:(MMDrawerSide)drawerSide{
UIViewController * sideDrawerViewController = [self sideDrawerViewControllerForSide:drawerSide];
[sideDrawerViewController.view.layer setAnchorPoint:CGPointMake(0.5f, 0.5f)];
[sideDrawerViewController.view.layer setTransform:CATransform3DIdentity];
[sideDrawerViewController.view setAlpha:1.0];
}
-(CGFloat)roundedOriginXForDrawerConstriants:(CGFloat)originX{
if (originX < -self.maximumRightDrawerWidth) {
if (self.shouldStretchDrawer &&
self.rightDrawerViewController) {
CGFloat maxOvershoot = (CGRectGetWidth(self.centerContainerView.frame)-self.maximumRightDrawerWidth)*MMDrawerOvershootPercentage;
return originXForDrawerOriginAndTargetOriginOffset(originX, -self.maximumRightDrawerWidth, maxOvershoot);
}
else{
return -self.maximumRightDrawerWidth;
}
}
else if(originX > self.maximumLeftDrawerWidth){
if (self.shouldStretchDrawer &&
self.leftDrawerViewController) {
CGFloat maxOvershoot = (CGRectGetWidth(self.centerContainerView.frame)-self.maximumLeftDrawerWidth)*MMDrawerOvershootPercentage;
return originXForDrawerOriginAndTargetOriginOffset(originX, self.maximumLeftDrawerWidth, maxOvershoot);
}
else{
return self.maximumLeftDrawerWidth;
}
}
return originX;
}
static inline CGFloat originXForDrawerOriginAndTargetOriginOffset(CGFloat originX, CGFloat targetOffset, CGFloat maxOvershoot){
CGFloat delta = ABS(originX - targetOffset);
CGFloat maxLinearPercentage = MMDrawerOvershootLinearRangePercentage;
CGFloat nonLinearRange = maxOvershoot * maxLinearPercentage;
CGFloat nonLinearScalingDelta = (delta - nonLinearRange);
CGFloat overshoot = nonLinearRange + nonLinearScalingDelta * nonLinearRange/sqrt(pow(nonLinearScalingDelta,2.f) + 15000);
if (delta < nonLinearRange) {
return originX;
}
else if (targetOffset < 0) {
return targetOffset - round(overshoot);
}
else{
return targetOffset + round(overshoot);
}
}
#pragma mark - Helpers
-(void)setupGestureRecognizers{
UIPanGestureRecognizer * pan = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(panGestureCallback:)];
[pan setDelegate:self];
[self.view addGestureRecognizer:pan];
UITapGestureRecognizer * tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapGestureCallback:)];
[tap setDelegate:self];
[self.view addGestureRecognizer:tap];
}
-(void)prepareToPresentDrawer:(MMDrawerSide)drawer animated:(BOOL)animated{
MMDrawerSide drawerToHide = MMDrawerSideNone;
if(drawer == MMDrawerSideLeft){
drawerToHide = MMDrawerSideRight;
}
else if(drawer == MMDrawerSideRight){
drawerToHide = MMDrawerSideLeft;
}
UIViewController * sideDrawerViewControllerToPresent = [self sideDrawerViewControllerForSide:drawer];
UIViewController * sideDrawerViewControllerToHide = [self sideDrawerViewControllerForSide:drawerToHide];
[self.childControllerContainerView sendSubviewToBack:sideDrawerViewControllerToHide.view];
[sideDrawerViewControllerToHide.view setHidden:YES];
[sideDrawerViewControllerToPresent.view setHidden:NO];
[self resetDrawerVisualStateForDrawerSide:drawer];
[sideDrawerViewControllerToPresent.view setFrame:sideDrawerViewControllerToPresent.mm_visibleDrawerFrame];
[self updateDrawerVisualStateForDrawerSide:drawer percentVisible:0.0];
[sideDrawerViewControllerToPresent beginAppearanceTransition:YES animated:animated];
}
-(void)updateShadowForCenterView{
UIView * centerView = self.centerContainerView;
if(self.showsShadow){
centerView.layer.masksToBounds = NO;
centerView.layer.shadowRadius = self.shadowRadius;
centerView.layer.shadowOpacity = self.shadowOpacity;
centerView.layer.shadowOffset = self.shadowOffset;
centerView.layer.shadowColor = [self.shadowColor CGColor];
/** In the event this gets called a lot, we won't update the shadowPath
unless it needs to be updated (like during rotation) */
if (centerView.layer.shadowPath == NULL) {
centerView.layer.shadowPath = [[UIBezierPath bezierPathWithRect:self.centerContainerView.bounds] CGPath];
}
else{
CGRect currentPath = CGPathGetPathBoundingBox(centerView.layer.shadowPath);
if (CGRectEqualToRect(currentPath, centerView.bounds) == NO){
centerView.layer.shadowPath = [[UIBezierPath bezierPathWithRect:self.centerContainerView.bounds] CGPath];
}
}
}
else if (centerView.layer.shadowPath != NULL) {
centerView.layer.shadowRadius = 0.f;
centerView.layer.shadowOpacity = 0.f;
centerView.layer.shadowOffset = CGSizeMake(0, -3);
centerView.layer.shadowPath = NULL;
centerView.layer.masksToBounds = YES;
}
}
-(NSTimeInterval)animationDurationForAnimationDistance:(CGFloat)distance{
NSTimeInterval duration = MAX(distance/self.animationVelocity,MMDrawerMinimumAnimationDuration);
return duration;
}
-(UIViewController*)sideDrawerViewControllerForSide:(MMDrawerSide)drawerSide{
UIViewController * sideDrawerViewController = nil;
if(drawerSide != MMDrawerSideNone){
sideDrawerViewController = [self childViewControllerForSide:drawerSide];
}
return sideDrawerViewController;
}
-(UIViewController*)childViewControllerForSide:(MMDrawerSide)drawerSide{
UIViewController * childViewController = nil;
switch (drawerSide) {
case MMDrawerSideLeft:
childViewController = self.leftDrawerViewController;
break;
case MMDrawerSideRight:
childViewController = self.rightDrawerViewController;
break;
case MMDrawerSideNone:
childViewController = self.centerViewController;
break;
}
return childViewController;
}
#pragma mark - UIGestureRecognizerDelegate
-(BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch{
if(self.openSide == MMDrawerSideNone){
MMOpenDrawerGestureMode possibleOpenGestureModes = [self possibleOpenGestureModesForGestureRecognizer:gestureRecognizer
withTouch:touch];
return ((self.openDrawerGestureModeMask & possibleOpenGestureModes)>0);
}
else{
MMCloseDrawerGestureMode possibleCloseGestureModes = [self possibleCloseGestureModesForGestureRecognizer:gestureRecognizer
withTouch:touch];
return ((self.closeDrawerGestureModeMask & possibleCloseGestureModes)>0);
}
}
#pragma mark Gesture Recogizner Delegate Helpers
-(MMCloseDrawerGestureMode)possibleCloseGestureModesForGestureRecognizer:(UIGestureRecognizer*)gestureRecognizer withTouch:(UITouch*)touch{
CGPoint point = [touch locationInView:self.childControllerContainerView];
MMCloseDrawerGestureMode possibleCloseGestureModes = MMCloseDrawerGestureModeNone;
if([gestureRecognizer isKindOfClass:[UITapGestureRecognizer class]]){
if([self isPointContainedWithinNavigationRect:point]){
possibleCloseGestureModes |= MMCloseDrawerGestureModeTapNavigationBar;
}
if([self isPointContainedWithinCenterViewContentRect:point]){
possibleCloseGestureModes |= MMCloseDrawerGestureModeTapCenterView;
}
}
else if([gestureRecognizer isKindOfClass:[UIPanGestureRecognizer class]]){
if([self isPointContainedWithinNavigationRect:point]){
possibleCloseGestureModes |= MMCloseDrawerGestureModePanningNavigationBar;
}
if([self isPointContainedWithinCenterViewContentRect:point]){
possibleCloseGestureModes |= MMCloseDrawerGestureModePanningCenterView;
}
if([self isPointContainedWithinRightBezelRect:point] &&
self.openSide == MMDrawerSideLeft){
possibleCloseGestureModes |= MMCloseDrawerGestureModeBezelPanningCenterView;
}
if([self isPointContainedWithinLeftBezelRect:point] &&
self.openSide == MMDrawerSideRight){
possibleCloseGestureModes |= MMCloseDrawerGestureModeBezelPanningCenterView;
}
if([self isPointContainedWithinCenterViewContentRect:point] == NO &&
[self isPointContainedWithinNavigationRect:point] == NO){
possibleCloseGestureModes |= MMCloseDrawerGestureModePanningDrawerView;
}
}
if((self.closeDrawerGestureModeMask & MMCloseDrawerGestureModeCustom) > 0 &&
self.gestureShouldRecognizeTouch){
if(self.gestureShouldRecognizeTouch(self,gestureRecognizer,touch)){
possibleCloseGestureModes |= MMCloseDrawerGestureModeCustom;
}
}
return possibleCloseGestureModes;
}
-(MMOpenDrawerGestureMode)possibleOpenGestureModesForGestureRecognizer:(UIGestureRecognizer*)gestureRecognizer withTouch:(UITouch*)touch{
CGPoint point = [touch locationInView:self.childControllerContainerView];
MMOpenDrawerGestureMode possibleOpenGestureModes = MMOpenDrawerGestureModeNone;
if([gestureRecognizer isKindOfClass:[UIPanGestureRecognizer class]]){
if([self isPointContainedWithinNavigationRect:point]){
possibleOpenGestureModes |= MMOpenDrawerGestureModePanningNavigationBar;
}
if([self isPointContainedWithinCenterViewContentRect:point]){
possibleOpenGestureModes |= MMOpenDrawerGestureModePanningCenterView;
}
if([self isPointContainedWithinLeftBezelRect:point] &&
self.leftDrawerViewController){
possibleOpenGestureModes |= MMOpenDrawerGestureModeBezelPanningCenterView;
}
if([self isPointContainedWithinRightBezelRect:point] &&
self.rightDrawerViewController){
possibleOpenGestureModes |= MMOpenDrawerGestureModeBezelPanningCenterView;
}
}
if((self.openDrawerGestureModeMask & MMOpenDrawerGestureModeCustom) > 0 &&
self.gestureShouldRecognizeTouch){
if(self.gestureShouldRecognizeTouch(self,gestureRecognizer,touch)){
possibleOpenGestureModes |= MMOpenDrawerGestureModeCustom;
}
}
return possibleOpenGestureModes;
}
-(BOOL)isPointContainedWithinNavigationRect:(CGPoint)point{
CGRect navigationBarRect = CGRectNull;
if([self.centerViewController isKindOfClass:[UINavigationController class]]){
UINavigationBar * navBar = [(UINavigationController*)self.centerViewController navigationBar];
navigationBarRect = [navBar convertRect:navBar.bounds toView:self.childControllerContainerView];
navigationBarRect = CGRectIntersection(navigationBarRect,self.childControllerContainerView.bounds);
}
return CGRectContainsPoint(navigationBarRect,point);
}
-(BOOL)isPointContainedWithinCenterViewContentRect:(CGPoint)point{
CGRect centerViewContentRect = self.centerContainerView.frame;
centerViewContentRect = CGRectIntersection(centerViewContentRect,self.childControllerContainerView.bounds);
return (CGRectContainsPoint(centerViewContentRect, point) &&
[self isPointContainedWithinNavigationRect:point] == NO);
}
-(BOOL)isPointContainedWithinLeftBezelRect:(CGPoint)point{
CGRect leftBezelRect = CGRectNull;
CGRect tempRect;
CGRectDivide(self.childControllerContainerView.bounds, &leftBezelRect, &tempRect, self.bezelPanningCenterViewRange, CGRectMinXEdge);
return (CGRectContainsPoint(leftBezelRect, point) &&
[self isPointContainedWithinCenterViewContentRect:point]);
}
-(BOOL)isPointContainedWithinRightBezelRect:(CGPoint)point{
CGRect rightBezelRect = CGRectNull;
CGRect tempRect;
CGRectDivide(self.childControllerContainerView.bounds, &rightBezelRect, &tempRect, self.bezelPanningCenterViewRange, CGRectMaxXEdge);
return (CGRectContainsPoint(rightBezelRect, point) &&
[self isPointContainedWithinCenterViewContentRect:point]);
}
@end
================================================
FILE: MMDrawerController/MMDrawerVisualState.h
================================================
// Copyright (c) 2013 Mutual Mobile (http://mutualmobile.com/)
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
#import
#import "MMDrawerController.h"
/**
`MMDrawerVisualState` provides prebuilt visual state update blocks that can be used in the callback block of `MMDrawerController` for drawer animation.
*/
@interface MMDrawerVisualState : NSObject
/**
Creates a slide and scale visual state block that gives an experience similar to Mailbox.app. It scales from 90% to 100%, and translates 50 pixels in the x direction. In addition, it also sets alpha from 0.0 to 1.0.
@return The visual state block.
*/
+(MMDrawerControllerDrawerVisualStateBlock)slideAndScaleVisualStateBlock;
/**
Creates a slide visual state block that gives the user an experience that slides at the same speed of the center view controller during animation. This is equal to calling `parallaxVisualStateBlockWithParallaxFactor:` with a parallax factor of 1.0.
@return The visual state block.
*/
+(MMDrawerControllerDrawerVisualStateBlock)slideVisualStateBlock;
/**
Creates a swinging door visual state block that gives the user an experience that animates the drawer in along the hinge.
@return The visual state block.
*/
+(MMDrawerControllerDrawerVisualStateBlock)swingingDoorVisualStateBlock;
/**
Creates a parallax experience that slides the side drawer view controller at a different rate than the center view controller during animation. For every parallaxFactor of points moved by the center view controller, the side drawer view controller will move 1 point. Passing in 1.0 is the equivalent of a applying a sliding animation, while passing in MAX_FLOAT is the equivalent of having no animation at all.
@param parallaxFactor The amount of parallax applied to the side drawer conroller. This value must be greater than 1.0. The closer the value is to 1.0, the faster the side drawer view controller will be parallaxing.
@return The visual state block.
*/
+(MMDrawerControllerDrawerVisualStateBlock)parallaxVisualStateBlockWithParallaxFactor:(CGFloat)parallaxFactor;
@end
================================================
FILE: MMDrawerController/MMDrawerVisualState.m
================================================
// Copyright (c) 2013 Mutual Mobile (http://mutualmobile.com/)
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
#import "MMDrawerVisualState.h"
#import
@implementation MMDrawerVisualState
+(MMDrawerControllerDrawerVisualStateBlock)slideAndScaleVisualStateBlock{
MMDrawerControllerDrawerVisualStateBlock visualStateBlock =
^(MMDrawerController * drawerController, MMDrawerSide drawerSide, CGFloat percentVisible){
CGFloat minScale = .90;
CGFloat scale = minScale + (percentVisible*(1.0-minScale));
CATransform3D scaleTransform = CATransform3DMakeScale(scale, scale, scale);
CGFloat maxDistance = 50;
CGFloat distance = maxDistance * percentVisible;
CATransform3D translateTransform = CATransform3DIdentity;
UIViewController * sideDrawerViewController;
if(drawerSide == MMDrawerSideLeft) {
sideDrawerViewController = drawerController.leftDrawerViewController;
translateTransform = CATransform3DMakeTranslation((maxDistance-distance), 0.0, 0.0);
}
else if(drawerSide == MMDrawerSideRight){
sideDrawerViewController = drawerController.rightDrawerViewController;
translateTransform = CATransform3DMakeTranslation(-(maxDistance-distance), 0.0, 0.0);
}
[sideDrawerViewController.view.layer setTransform:CATransform3DConcat(scaleTransform, translateTransform)];
[sideDrawerViewController.view setAlpha:percentVisible];
};
return visualStateBlock;
}
+(MMDrawerControllerDrawerVisualStateBlock)slideVisualStateBlock{
return [self parallaxVisualStateBlockWithParallaxFactor:1.0];
}
+(MMDrawerControllerDrawerVisualStateBlock)swingingDoorVisualStateBlock{
MMDrawerControllerDrawerVisualStateBlock visualStateBlock =
^(MMDrawerController * drawerController, MMDrawerSide drawerSide, CGFloat percentVisible){
UIViewController * sideDrawerViewController;
CGPoint anchorPoint;
CGFloat maxDrawerWidth = 0.0;
CGFloat xOffset;
CGFloat angle = 0.0;
if(drawerSide==MMDrawerSideLeft){
sideDrawerViewController = drawerController.leftDrawerViewController;
anchorPoint = CGPointMake(1.0, .5);
maxDrawerWidth = MAX(drawerController.maximumLeftDrawerWidth,drawerController.visibleLeftDrawerWidth);
xOffset = -(maxDrawerWidth/2.0) + (maxDrawerWidth)*percentVisible;
angle = -M_PI_2+(percentVisible*M_PI_2);
}
else {
sideDrawerViewController = drawerController.rightDrawerViewController;
anchorPoint = CGPointMake(0.0, .5);
maxDrawerWidth = MAX(drawerController.maximumRightDrawerWidth,drawerController.visibleRightDrawerWidth);
xOffset = (maxDrawerWidth/2.0) - (maxDrawerWidth)*percentVisible;
angle = M_PI_2-(percentVisible*M_PI_2);
}
[sideDrawerViewController.view.layer setAnchorPoint:anchorPoint];
[sideDrawerViewController.view.layer setShouldRasterize:YES];
[sideDrawerViewController.view.layer setRasterizationScale:[[UIScreen mainScreen] scale]];
CATransform3D swingingDoorTransform = CATransform3DIdentity;
if (percentVisible <= 1.f) {
CATransform3D identity = CATransform3DIdentity;
identity.m34 = -1.0/1000.0;
CATransform3D rotateTransform = CATransform3DRotate(identity, angle, 0.0, 1.0, 0.0);
CATransform3D translateTransform = CATransform3DMakeTranslation(xOffset, 0.0, 0.0);
CATransform3D concatTransform = CATransform3DConcat(rotateTransform, translateTransform);
swingingDoorTransform = concatTransform;
}
else{
CATransform3D overshootTransform = CATransform3DMakeScale(percentVisible, 1.f, 1.f);
NSInteger scalingModifier = 1.f;
if (drawerSide == MMDrawerSideRight) {
scalingModifier = -1.f;
}
overshootTransform = CATransform3DTranslate(overshootTransform, scalingModifier*maxDrawerWidth/2, 0.f, 0.f);
swingingDoorTransform = overshootTransform;
}
[sideDrawerViewController.view.layer setTransform:swingingDoorTransform];
};
return visualStateBlock;
}
+(MMDrawerControllerDrawerVisualStateBlock)parallaxVisualStateBlockWithParallaxFactor:(CGFloat)parallaxFactor{
MMDrawerControllerDrawerVisualStateBlock visualStateBlock =
^(MMDrawerController * drawerController, MMDrawerSide drawerSide, CGFloat percentVisible){
NSParameterAssert(parallaxFactor >= 1.0);
CATransform3D transform = CATransform3DIdentity;
UIViewController * sideDrawerViewController;
if(drawerSide == MMDrawerSideLeft) {
sideDrawerViewController = drawerController.leftDrawerViewController;
CGFloat distance = MAX(drawerController.maximumLeftDrawerWidth,drawerController.visibleLeftDrawerWidth);
if (percentVisible <= 1.f) {
transform = CATransform3DMakeTranslation((-distance)/parallaxFactor+(distance*percentVisible/parallaxFactor), 0.0, 0.0);
}
else{
transform = CATransform3DMakeScale(percentVisible, 1.f, 1.f);
transform = CATransform3DTranslate(transform, drawerController.maximumLeftDrawerWidth*(percentVisible-1.f)/2, 0.f, 0.f);
}
}
else if(drawerSide == MMDrawerSideRight){
sideDrawerViewController = drawerController.rightDrawerViewController;
CGFloat distance = MAX(drawerController.maximumRightDrawerWidth,drawerController.visibleRightDrawerWidth);
if(percentVisible <= 1.f){
transform = CATransform3DMakeTranslation((distance)/parallaxFactor-(distance*percentVisible)/parallaxFactor, 0.0, 0.0);
}
else{
transform = CATransform3DMakeScale(percentVisible, 1.f, 1.f);
transform = CATransform3DTranslate(transform, -drawerController.maximumRightDrawerWidth*(percentVisible-1.f)/2, 0.f, 0.f);
}
}
[sideDrawerViewController.view.layer setTransform:transform];
};
return visualStateBlock;
}
@end
================================================
FILE: MMDrawerController/UIViewController+MMDrawerController.h
================================================
// Copyright (c) 2013 Mutual Mobile (http://mutualmobile.com/)
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
#import
#import "MMDrawerController.h"
/**
A helper category on `UIViewController` that exposes the parent drawer controller, the visible side drawer frame, and a `mm_drawerWillAppear` method that is called when the drawer is about to appear.
*/
@interface UIViewController (MMDrawerController)
///---------------------------------------
/// @name Accessing Drawer View Controller Properties
///---------------------------------------
/**
The `MMDrawerController` that the view controller is contained within. If the view controller is not contained within a `MMDrawerController`, this property is nil. Note that if the view controller is contained within a `UINavigationController`, that navigation controller is contained within a `MMDrawerController`, this property will return a refernce to the `MMDrawerController`, despite the fact that it is not the direct parent of the view controller.
*/
@property(nonatomic, strong, readonly) MMDrawerController *mm_drawerController;
/**
The visible rect of the side drawer view controller in the drawer controller coordinate space. If the view controller is not a drawer in a `MMDrawerController`, then this property returns `CGRectNull`
*/
@property(nonatomic, assign, readonly) CGRect mm_visibleDrawerFrame;
@end
================================================
FILE: MMDrawerController/UIViewController+MMDrawerController.m
================================================
// Copyright (c) 2013 Mutual Mobile (http://mutualmobile.com/)
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
#import "UIViewController+MMDrawerController.h"
@implementation UIViewController (MMDrawerController)
-(MMDrawerController*)mm_drawerController{
UIViewController *parentViewController = self.parentViewController;
while (parentViewController != nil) {
if([parentViewController isKindOfClass:[MMDrawerController class]]){
return (MMDrawerController *)parentViewController;
}
parentViewController = parentViewController.parentViewController;
}
return nil;
}
-(CGRect)mm_visibleDrawerFrame{
if([self isEqual:self.mm_drawerController.leftDrawerViewController] ||
[self.navigationController isEqual:self.mm_drawerController.leftDrawerViewController]){
CGRect rect = self.mm_drawerController.view.bounds;
rect.size.width = self.mm_drawerController.maximumLeftDrawerWidth;
if (self.mm_drawerController.showsStatusBarBackgroundView) {
rect.size.height -= 20.0f;
}
return rect;
}
else if([self isEqual:self.mm_drawerController.rightDrawerViewController] ||
[self.navigationController isEqual:self.mm_drawerController.rightDrawerViewController]){
CGRect rect = self.mm_drawerController.view.bounds;
rect.size.width = self.mm_drawerController.maximumRightDrawerWidth;
rect.origin.x = CGRectGetWidth(self.mm_drawerController.view.bounds)-rect.size.width;
if (self.mm_drawerController.showsStatusBarBackgroundView) {
rect.size.height -= 20.0f;
}
return rect;
}
else {
return CGRectNull;
}
}
@end
================================================
FILE: MMDrawerController.podspec
================================================
Pod::Spec.new do |s|
s.name = "MMDrawerController"
s.version = "0.6.0"
s.summary = "A lightweight, easy-to-use side drawer navigation controller."
s.homepage = "https://github.com/mutualmobile/MMDrawerController"
s.license = { :type => 'MIT', :file => 'LICENSE' }
s.author = { "Kevin Harwood" => "kevin.harwood@mutualmobile.com" }
s.source = { :git => "https://github.com/mutualmobile/MMDrawerController.git", :tag => "0.6.0" }
s.platform = :ios, '7.0'
s.requires_arc = true
s.screenshots = [ "http://mutualmobile.github.io/MMDrawerController/ExampleImages/example1.png",
"http://mutualmobile.github.io/MMDrawerController/ExampleImages/example2.png" ]
s.subspec 'Core' do |ss|
ss.source_files = 'MMDrawerController/MMDrawerController.{h,m}', 'MMDrawerController/UIViewController+MMDrawerController*'
ss.framework = 'QuartzCore'
end
s.subspec 'MMDrawerBarButtonItem' do |ss|
ss.source_files = 'MMDrawerController/MMDrawerBarButtonItem.{h,m}'
ss.dependency 'MMDrawerController/Core'
end
s.subspec 'MMDrawerVisualStates' do |ss|
ss.source_files = 'MMDrawerController/MMDrawerVisualState.{h,m}'
ss.dependency 'MMDrawerController/Core'
end
s.subspec 'Subclass' do |ss|
ss.source_files = 'MMDrawerController/MMDrawerController+Subclass.h'
ss.dependency 'MMDrawerController/Core'
end
end
================================================
FILE: README.md
================================================
#Mutual Mobile Drawer Controller
`MMDrawerController` is a side drawer navigation container view controller designed to support the growing number of applications that leverage the side drawer paradigm. This library is designed to exclusively support side drawer navigation in a light-weight, focused approach while exposing the ability to provide custom animations for presenting and dismissing the drawer.
---
##Documentation
Official appledoc documentation can be found at [CocoaDocs](http://cocoadocs.org/docsets/MMDrawerController/).
---
##Installing MMDrawerController
You can install MMDrawerController in your project by using [CocoaPods](https://github.com/cocoapods/cocoapods):
```Ruby
pod 'MMDrawerController', '~> 0.5.7'
```
---
##Creating a Drawer Controller
Creating a `MMDrawerController` is as easy as creating a center view controller and the drawer view controllers, and init'ing the drawer.
```Objective-C
UIViewController * leftDrawer = [[UIViewController alloc] init];
UIViewController * center = [[UIViewController alloc] init];
UIViewController * rightDrawer = [[UIViewController alloc] init];
MMDrawerController * drawerController = [[MMDrawerController alloc]
initWithCenterViewController:center
leftDrawerViewController:leftDrawer
rightDrawerViewController:rightDrawer];
```
---
##Features
###UINavigationController Support
`MMDrawerController` seamlessly accepts a `UINavigationController` as the `centerViewController`, and will update all of the gesture support automatically. In addition, any child view controller contained within the `UINavigationController` will have access to the parent drawer controller using the category explained [below](#accessing-the-drawer-controller-from-a-child-view-controller).
###UIGestureRecognizer Support
`MMDrawerController` exposes gesture support for opening and closing the drawer through two masks, one for opening and one for closing. The options are as follows:
* **MMOpenDrawerGestureMode**
* **MMOpenDrawerGestureModePanningNavigationBar**: The user can open the drawer by panning anywhere on the navigation bar.
* **MMOpenDrawerGestureModePanningCenterView**: The user can open the drawer by panning anywhere on the center view.
* **MMOpenDrawerGestureModeBezelPanningCenterView**: The user can open the drawer by starting a pan anywhere within 20 points of the bezel.
* **MMOpenDrawerGestureModeCustom**: The developer can provide a callback block to determine if the gesture should be recognized. More information below.
* **MMCloseDrawerGestureMode**
* **MMCloseDrawerGestureModePanningNavigationBar**: The user can close the drawer by panning anywhere on the navigation bar.
* **MMCloseDrawerGestureModePanningCenterView**: The user can close the drawer by panning anywhere on the center view.
* **MMCloseDrawerGestureModeBezelPanningCenterView**: The user can close the drawer by starting a pan anywhere within the bezel of the center view.
* **MMCloseDrawerGestureModeTapNavigationBar**: The user can close the drawer by tapping the navigation bar.
* **MMCloseDrawerGestureModeTapCenterView**: The user can close the drawer by tapping the center view.
* **MMCloseDrawerGestureModePanningDrawerView**: The user can close the drawer by panning anywhere on the drawer view.
* **MMCloseDrawerGestureModeCustom**: The developer can provide a callback block to determine if the gesture should be recognized. More information below.
You are free to set whatever combination you want for opening and closing. Note that these gestures may impact touches sent to the child view controllers, so be sure to use these appropriately for your application. For example, you wouldn't want `MMOpenDrawerGestureModePanningCenterView` set if a `MKMapView` is your center view controller, since it would intercept the pan meant for moving around the map.
####Custom Gesture Recognizer Support
Starting with version 0.3.0, you can now provide a callback block to determine if a gesture should be recognized using the `setGestureShouldRecognizeTouchBlock:` method. This method provides three parameters - the drawer controller, the gesture, and the touch. As a developer, you are responsible for inspecting those elements and determining if the gesture should be recognized or not. Note the block is only consulted if you have set `MMOpenDrawerGestureModeCustom`/`MMCloseDrawerGestureModeCustom` on the appropriate mask.
For example, lets say you have a center view controller that contains a few elements, and you only want the pan gesture to be recognized to open the drawer when the touch begins within a certain subview. You would make sure that the `openDrawerGestureModeMask` contains `MMOpenDrawerGestureModeCustom`, and you could set a block below as so:
```Objective-C
[myDrawerController
setGestureShouldRecognizeTouchBlock:^BOOL(MMDrawerController *drawerController, UIGestureRecognizer *gesture, UITouch *touch) {
BOOL shouldRecognizeTouch = NO;
if(drawerController.openSide == MMDrawerSideNone &&
[gesture isKindOfClass:[UIPanGestureRecognizer class]]){
UIView * customView = [drawerController.centerViewController myCustomSubview];
CGPoint location = [touch locationInView:customView];
shouldRecognizeTouch = (CGRectContainsPoint(customView.bounds, location));
}
return shouldRecognizeTouch;
}];
```
Note that you would not want the `openDrawerGestureModeMask` to contain `MMOpenDrawerGestureModePanningCenterView`, since that would take over and be applied automatically regardless of where the touch begins within the center view.
###Custom Drawer Open/Close Animations
`MMDrawerController` provides a callback block that allows you to implement your own custom state for the drawer controller when an open/close or pan gesture event happens. Within the block, you are responsible for updating the visual state of the drawer controller, and the drawer controller will handle animating to that state.
For example, to set the alpha of the side drawer controller from 0 to 1 during an animation, you would do the following:
```Objective-C
[drawerController
setDrawerVisualStateBlock:^(MMDrawerController *drawerController, MMDrawerSide drawerSide, CGFloat percentVisible) {
UIViewController * sideDrawerViewController;
if(drawerSide == MMDrawerSideLeft){
sideDrawerViewController = drawerController.leftDrawerViewController;
}
else if(drawerSide == MMDrawerSideRight){
sideDrawerViewController = drawerController.rightDrawerViewController;
}
[sideDrawerViewController.view setAlpha:percentVisible];
}];
```
In addition, `MMDrawerController` ships with several prebuilt animations to let you go crazy right out of the box. These are included as a subspec for the project, and more information can be found [below](#prebuilt-example-animations).
###Center View Controller Interaction Mode
When a drawer is open, you can control how a user can interact with the center view controller.
* **MMDrawerOpenCenterInteractionModeNone**: The user can not interact with any content in the center view.
* **MMDrawerOpenCenterInteractionModeFull**: The user can interact with all content in the center view.
* **MMDrawerOpenCenterInteractionModeNavigationBarOnly**: The user can interact with only content on the navigation bar. The setting allows the menu button to still respond, allowing you to toggle the drawer closed when it is open. This is the default setting.
###Accessing the Drawer Controller from a Child View Controller
You can use the `UIViewController+MMDrawerController` category in order to query the drawerController directly from child view controllers.
###State Restoration
Beginning with 0.4.0, `MMDrawerController` supports iOS state restoration. In order to opt in to state restoration for `MMDrawerController`, you must set the `restorationIdentifier` of your drawer controller. Instances of your `centerViewController`, `leftDrawerViewController` and `rightDrawerViewController` must also be configured with their own `restorationIdentifier` (and optionally a restorationClass) if you intend for those to be restored as well. If your MMDrawerController had an open drawer when your app was sent to the background, that state will also be restored.
##iOS 7 Status Bar Support
###Child View Controller Support
Beginning with iOS 7, the child view controllers will by default determine the state of the status bar, including its' style and whether or not it is hidden. This value will also be updated anytime the open side changes state, meaning that a side drawer can provide a different value than the center view controller.
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 draw 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.
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.
---
##Subclassing
If you plan to subclass `MMDrawerController`, import `MMDrawerController+Subclass.h` into your subclass to access protected methods for `MMDrawerController.` Note that several methods assume and require you to call super, so be sure to follow that convention.
If there is specific functionality you need that is not supported by these methods, please open a Github issue explaining your needs and we can try and find a way to open up methods that can help you out.
---
##Bells and Whistles
A few extras to make your life easier...
###MMDrawerBarButtonItem
Using Paint Code, we created a standard Menu Button that you can use in any `UINavigationBar`, and make it whatever color you want. It's included as a subspec to this library. Enjoy.
Starting with iOS 7, the drawer button is now drawn in a much thinner stroke. In addition, the color methods have been deprecated, and the color will now be determined by the `tintColor.` Also note that the shadow has been deprecated to be more in line with the design themes of the OS.
###Prebuilt Example Animations
In order to make it as easy as possible for you to use this library, we built some of the common animations we see out there today. Simply include the `MMDrawerVisualStates` subspec, and use any of the prebuilt visual states.
For example, if you wanted to use a slide and scale animation, you would do the following:
```Objective-C
[drawerController setDrawerVisualStateBlock:[MMDrawerVisualState slideAndScaleVisualStateBlock]];
```
And that's it...
Here's a quick list of the built in animations:
* **Slide**: The drawer slides at the same rate as the center view controller.
* **Slide and Scale**: The drawer slides and scales up at the same time, while also alpha'ing from 0.0 to 1.0.
* **Swinging Door**: The drawer swings in along a hinge on the center view controller.
* **Parallax**: The drawer slides in at a slower rate than the center view controller, giving a parallax effect.
###Stretchy Drawer
By default, the side drawer will stretch if the user pans past the maximum drawer width. This gives a playful stretch effect. You can disable this by setting `shouldStretchDrawer` to NO, or you can make your own overshoot animation by creating a custom visual state block and setting up custom transforms for when percentVisible is greater than 1.0
###Bounce Preview
To make your side drawer more discoverable, it may be helpful to bounce the drawer the first time your user launches the app. You can use the `bouncePreviewForDrawerSide:completion:` method to easily do this.
If you would like to bounce a custom distance, you can use `bouncePreviewForDrawerSide:distance:completion:`.
###Nifty Example
We decided to spruce up the example a bit using graphics generated from PaintCode. Hope you like it.
The example shows off all the features of the library. Give it a whirl.
---
##What this Library Doesn't Do
In order to keep this library light-weight, we had to make some design trade off decisions. Specifically, we decided this library would NOT DO the following:
* Top or bottom drawer views
* Displaying both drawers at one time
* Displaying a minimum drawer width
* Support container view controllers other than `UINavigationController` (such as `UITabBarController` or `UISplitViewController`) as the center view controller.
* Support presenting the drawer above the center view controller (like the Google+ app).
We're sure this list will grow over time. But that's the cost of keeping something maintainable :)
---
##Workarounds/FAQs
####How do I support editing/dragging cells in a tableview in the center view controller?
The best way to support this is to set the open/close mask to `MMOpenDrawerGestureModeNone` / `MMCloseDrawerGestureModeNone` while editing is enabled, and restore the mask when editing is finished. This will allow the proper gestures/touches to be passed all the way to the table view. ([#184](https://github.com/mutualmobile/MMDrawerController/issues/184))
---
##Credit
Designed and Developed by these fine folks at [Mutual Mobile](http://mutualmobile.com):
###Development
* [Kevin Harwood](http://twitter.com/kevinharwood)
* [Lars Anderson](http://twitter.com/theonlylars)
* [Rene Cacheaux](http://twitter.com/rcachatx)
* [Conrad Stoll](http://twitter.com/conradstoll)
###Design
* [Matt McDaniel](http://twitter.com/supermattzor)
---
##Feedback
We'd love to hear feedback on the library. Create Github issues, or hit us up on Twitter.
---
##License
`MMDrawerController` is available under the MIT license. See the LICENSE file for more info.