├── .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 ├── Icons │ ├── Icon-72.png │ ├── Icon-72@2x.png │ ├── Icon.png │ └── Icon@2x.png └── MMDrawerControllerKitchenSink.xcodeproj │ ├── project.pbxproj │ ├── project.xcworkspace │ ├── contents.xcworkspacedata │ └── xcshareddata │ │ └── MMDrawerControllerKitchenSink.xccheckout │ └── xcshareddata │ └── xcschemes │ └── MMDrawerControllerKitchenSink.xcscheme ├── LICENSE ├── MMDrawerController.podspec ├── MMDrawerController ├── MMDrawerBarButtonItem.h ├── MMDrawerBarButtonItem.m ├── MMDrawerController+Subclass.h ├── MMDrawerController.h ├── MMDrawerController.m ├── MMDrawerVisualState.h ├── MMDrawerVisualState.m ├── UIViewController+MMDrawerController.h └── UIViewController+MMDrawerController.m └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | # Xcode 2 | .DS_Store 3 | */build/* 4 | *.pbxuser 5 | !default.pbxuser 6 | *.mode1v3 7 | !default.mode1v3 8 | *.mode2v3 9 | !default.mode2v3 10 | *.perspectivev3 11 | !default.perspectivev3 12 | xcuserdata 13 | profile 14 | *.moved-aside 15 | DerivedData 16 | .idea/ 17 | *.hmap 18 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: objective-c 2 | script: xcodebuild -project KitchenSink/MMDrawerControllerKitchenSink.xcodeproj/ -scheme MMDrawerControllerKitchenSink -sdk iphonesimulator ONLY_ACTIVE_ARCH=NO -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | #MMDrawerController Changelog 2 | ##[0.6.0](https://github.com/mutualmobile/MMDrawerController/issues?q=milestone%3A0.6.0+is%3Aclosed) (Thursday, April 2, 2015) 3 | ###New 4 | * **Removed iOS 6 support** ([#350](https://github.com/mutualmobile/MMDrawerController/pull/350))([#356](https://github.com/mutualmobile/MMDrawerController/pull/356)) (Kevin Harwood, podkovyrin) 5 | * **Migrated from id to instancetype** ([#349](https://github.com/mutualmobile/MMDrawerController/pull/349)) (Kevin Harwood) 6 | * **Added iPhone 6/6+ support to example project** ([#347](https://github.com/mutualmobile/MMDrawerController/pull/347)) (Kevin Harwood) 7 | * **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) 8 | 9 | ###Fixed 10 | * **FIXED** an issue ([#288](https://github.com/mutualmobile/MMDrawerController/pull/288)) rotation methods were called twice on iOS 8. (arielitovsky) 11 | * **FIXED** an issue ([#348](https://github.com/mutualmobile/MMDrawerController/pull/348)) where the drawer height was incorrectly set when using a dummy status bar. 12 | * **FIXED** an issue ([#324](https://github.com/mutualmobile/MMDrawerController/pull/324)) where we called removeFromParentViewController out of order. (long) 13 | * **FIXED** an issue ([#306](https://github.com/mutualmobile/MMDrawerController/pull/306)) where the podspec incorrectly caused a duplicate reference warning. (klundberg) 14 | 15 | ##[0.5.7](https://github.com/mutualmobile/MMDrawerController/issues?q=milestone%3A0.5.7+is%3Aclosed) (Monday, August 25th, 2014) 16 | ###Fixed 17 | * **FIXED** an issue ([#271](https://github.com/mutualmobile/MMDrawerController/pull/271)) where state restoration would cause multiple calls to viewDidAppear. (pronebird) 18 | * **FIXED** an issue ([#269](https://github.com/mutualmobile/MMDrawerController/pull/269)) where an internal method name was misnamed. (shoecart) 19 | 20 | ##[0.5.6](https://github.com/mutualmobile/MMDrawerController/issues?milestone=14&page=1&state=closed) (Monday, June 9th, 2014) 21 | ###Fixed 22 | * **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) 23 | * **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) 24 | * **FIXED** an issue ([#246](https://github.com/mutualmobile/MMDrawerController/pull/246)) where user could interact with content while an animation completed. (jgallagher, Kevin Harwood) 25 | * **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) 26 | * **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) 27 | * **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) 28 | 29 | ##[0.5.5](https://github.com/mutualmobile/MMDrawerController/releases/tag/0.5.5) (Wednesday, April 30, 2014) 30 | ###Fixed 31 | * **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) 32 | 33 | ##[0.5.4](https://github.com/mutualmobile/MMDrawerController/releases/tag/0.5.4) (Tuesday, April 15, 2014) 34 | ###Fixed 35 | * **FIXED** an issue ([#240](https://github.com/mutualmobile/MMDrawerController/pull/240)) where the center container view controller would be init'ed twice. (Lars Anderson) 36 | * **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) 37 | * **FIXED** an issue ([#224](https://github.com/mutualmobile/MMDrawerController/pull/224)) where we had some unreachable code. (tewha) 38 | 39 | 40 | ##[0.5.3](https://github.com/mutualmobile/MMDrawerController/releases/tag/0.5.3) (Tuesday, February 18, 2014) 41 | ###Fixed 42 | * **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. 43 | 44 | ##[0.5.2](https://github.com/mutualmobile/MMDrawerController/releases/tag/0.5.2) (Friday, January 31, 2014) 45 | ###New 46 | * **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) 47 | 48 | ###Fixed 49 | * **FIXED** a Clang Analyzer issue ([#120](https://github.com/mutualmobile/MMDrawerController/pull/120)) found in Xcode 5. (klundberg) 50 | * **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) 51 | * **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) 52 | * **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) 53 | * **FIXED** an issue ([#177](https://github.com/mutualmobile/MMDrawerController/pull/177)) where disabling the shadow caused a performance issue in iOS 7. (Lars Anderson) 54 | * **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) 55 | * **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) 56 | 57 | ##[0.5.1](https://github.com/mutualmobile/MMDrawerController/releases/tag/0.5.1) (Wednesday, September 18, 2013) 58 | ###Fixed 59 | * **FIXED** an issue ([#110](https://github.com/mutualmobile/MMDrawerController/pull/110)) where you could not compile for iOS 6 using Xcode 4.6.3. 60 | 61 | ##[0.5.0](https://github.com/mutualmobile/MMDrawerController/releases/tag/0.5.0) (Tuesday, September 17, 2013) 62 | ###New 63 | * **iOS 7 Support** - Compiled to work with iOS 7 64 | * **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. 65 | * **MMDrawerBarButtonItem Design** - Now designed to fit in with the iOS 7 aesthetic. 66 | * **MMDrawerBarButtonItem TintColor** - Now uses tintColor in iOS 7. 67 | * Example project now runs in both iOS 6 and iOS 7 with two different visual designs. 68 | 69 | ###Known Issues 70 | * 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). 71 | 72 | ##[0.4.0](https://github.com/mutualmobile/MMDrawerController/issues?milestone=8&page=1&state=closed) (Monday, August 19, 2013) 73 | ###New 74 | * **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) 75 | * **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) 76 | * **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) 77 | * **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) 78 | 79 | ###Fixed 80 | * **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) 81 | * **FIXED** an issue ([#63](https://github.com/mutualmobile/MMDrawerController/pull/63)) where the visual state block received invalid transform values. (Kevin Harwood) 82 | * **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) 83 | * **FIXED** an issue ([#80](https://github.com/mutualmobile/MMDrawerController/pull/80)) where the block parameters were not named appropriately. (Kevin Harwood, Joao Nunes) 84 | 85 | ##[0.3.0](https://github.com/mutualmobile/MMDrawerController/issues?milestone=6&page=1&state=closed) (Monday, July 22nd, 2013) 86 | ###New 87 | * 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) 88 | 89 | ###Fixed 90 | * **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) 91 | * **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) 92 | 93 | ##[0.2.1](https://github.com/mutualmobile/MMDrawerController/issues?milestone=7&state=closed) (Friday, June 21st, 2013) 94 | ###Fixed 95 | * **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) 96 | 97 | ##[0.2.0](https://github.com/mutualmobile/MMDrawerController/issues?milestone=5&state=closed) (Tuesday, June 4th, 2013) 98 | ###New 99 | * 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) 100 | * Added a new callback block to get notified when a gesture animation has completed ([#20](https://github.com/mutualmobile/MMDrawerController/issues/20)). (Kevin Harwood) 101 | 102 | ###Fixed 103 | * **FIXED** an issue([#23](https://github.com/mutualmobile/MMDrawerController/issues/23)) where the drawer could bounce, even if a drawer was open. (Kevin Harwood) 104 | * **FIXED** an issue([#38](https://github.com/mutualmobile/MMDrawerController/issues/38)) the designator initializer for `UIViewController` was not properly setting default values. (poteryaysya) 105 | * **FIXED** an issue([#24](https://github.com/mutualmobile/MMDrawerController/issues/24)) where some documentation was incorrect. (Kevin Harwood) 106 | 107 | ##[0.1.0](https://github.com/mutualmobile/MMDrawerController/issues?milestone=3&page=1&state=closed) (Wednesday, May 15th, 2013) 108 | ###New 109 | * `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) 110 | 111 | ###Fixed 112 | * **FIXED** an issue([#9](https://github.com/mutualmobile/MMDrawerController/issues/9)) where the drawer could bounce, even if no drawer was set. (Kevin Harwood) 113 | * **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) 114 | 115 | ###Deprecated 116 | * 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. 117 | 118 | ##[0.0.2](https://github.com/mutualmobile/MMDrawerController/issues?milestone=2&state=closed) (Thursday, May 9th, 2013) 119 | ###New 120 | * Improved the example to allow you to disable the left or right side drawer controller. (Kevin Harwood) 121 | 122 | ###Fixed 123 | * **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) 124 | * **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) 125 | 126 | ##0.0.1 (Wednesday, May 8th, 2013) 127 | * Initial Library Release 128 | -------------------------------------------------------------------------------- /KitchenSink/ExampleFiles/LaunchScreen.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 24 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /KitchenSink/ExampleFiles/MMAppDelegate.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2013 Mutual Mobile (http://mutualmobile.com/) 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a copy 4 | // of this software and associated documentation files (the "Software"), to deal 5 | // in the Software without restriction, including without limitation the rights 6 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | // copies of the Software, and to permit persons to whom the Software is 8 | // furnished to do so, subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included in 11 | // all copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | // THE SOFTWARE. 20 | 21 | 22 | #import 23 | 24 | @interface MMAppDelegate : UIResponder 25 | 26 | @property (strong, nonatomic) UIWindow *window; 27 | 28 | @end 29 | -------------------------------------------------------------------------------- /KitchenSink/ExampleFiles/MMAppDelegate.m: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2013 Mutual Mobile (http://mutualmobile.com/) 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a copy 4 | // of this software and associated documentation files (the "Software"), to deal 5 | // in the Software without restriction, including without limitation the rights 6 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | // copies of the Software, and to permit persons to whom the Software is 8 | // furnished to do so, subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included in 11 | // all copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | // THE SOFTWARE. 20 | 21 | 22 | #import "MMAppDelegate.h" 23 | #import "MMDrawerController.h" 24 | #import "MMExampleCenterTableViewController.h" 25 | #import "MMExampleLeftSideDrawerViewController.h" 26 | #import "MMExampleRightSideDrawerViewController.h" 27 | #import "MMDrawerVisualState.h" 28 | #import "MMExampleDrawerVisualStateManager.h" 29 | #import "MMNavigationController.h" 30 | 31 | #import 32 | 33 | @interface MMAppDelegate () 34 | @property (nonatomic,strong) MMDrawerController * drawerController; 35 | 36 | @end 37 | 38 | @implementation MMAppDelegate 39 | -(BOOL)application:(UIApplication *)application willFinishLaunchingWithOptions:(NSDictionary *)launchOptions{ 40 | 41 | //创建 左中右 控制器 42 | UIViewController * leftSideDrawerViewController = [[MMExampleLeftSideDrawerViewController alloc] init]; 43 | 44 | UIViewController * centerViewController = [[MMExampleCenterTableViewController alloc] init]; 45 | 46 | UIViewController * rightSideDrawerViewController = [[MMExampleRightSideDrawerViewController alloc] init]; 47 | 48 | //设置 重用标识 有了这个 程序再哪个页面杀死 再启动就会进入这个页面 好神奇 49 | UINavigationController * navigationController = [[MMNavigationController alloc] initWithRootViewController:centerViewController]; 50 | [navigationController setRestorationIdentifier:@"MMExampleCenterNavigationControllerRestorationKey"]; 51 | UINavigationController * rightSideNavController = [[MMNavigationController alloc] initWithRootViewController:rightSideDrawerViewController]; 52 | [rightSideNavController setRestorationIdentifier:@"MMExampleRightNavigationControllerRestorationKey"]; 53 | UINavigationController * leftSideNavController = [[MMNavigationController alloc] initWithRootViewController:leftSideDrawerViewController]; 54 | [leftSideNavController setRestorationIdentifier:@"MMExampleLeftNavigationControllerRestorationKey"]; 55 | 56 | 57 | //凭借 上面的 左中右 控制器 创建 他们的控制器容器 drawerController 58 | self.drawerController = [[MMDrawerController alloc] 59 | initWithCenterViewController:navigationController 60 | leftDrawerViewController:leftSideNavController 61 | rightDrawerViewController:rightSideNavController]; 62 | [self.drawerController setShowsShadow:NO]; 63 | //重用 标识 64 | [self.drawerController setRestorationIdentifier:@"MMDrawer"]; 65 | //右控制器 宽度 66 | [self.drawerController setMaximumRightDrawerWidth:200.0]; 67 | 68 | //手势开关: 打开 左右两侧 控制器 69 | [self.drawerController setOpenDrawerGestureModeMask:MMOpenDrawerGestureModeAll]; 70 | //手势开关: 关闭 左右两侧 控制器 71 | [self.drawerController setCloseDrawerGestureModeMask:MMCloseDrawerGestureModeAll]; 72 | 73 | //左右 控制器打开的效果 这里设置了 视觉差 效果 74 | [self.drawerController 75 | setDrawerVisualStateBlock:^(MMDrawerController *drawerController, MMDrawerSide drawerSide, CGFloat percentVisible) { 76 | MMDrawerControllerDrawerVisualStateBlock block; 77 | //左边/右边 控制器 view 的变化效果 78 | block = [[MMExampleDrawerVisualStateManager sharedManager] 79 | drawerVisualStateBlockForDrawerSide:drawerSide]; 80 | if(block){ 81 | block(drawerController, drawerSide, percentVisible); 82 | } 83 | }]; 84 | 85 | self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; 86 | 87 | UIColor * tintColor = [UIColor colorWithRed:29.0/255.0 88 | green:173.0/255.0 89 | blue:234.0/255.0 90 | alpha:1.0]; 91 | //设置 项目所有 tintColor:线条 颜色 92 | [self.window setTintColor:tintColor]; 93 | [self.window setRootViewController:self.drawerController]; 94 | 95 | return YES; 96 | } 97 | 98 | 99 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 100 | { 101 | self.window.backgroundColor = [UIColor whiteColor]; 102 | [self.window makeKeyAndVisible]; 103 | 104 | return YES; 105 | } 106 | 107 | - (BOOL)application:(UIApplication *)application shouldSaveApplicationState:(NSCoder *)coder{ 108 | return YES; 109 | } 110 | 111 | - (BOOL)application:(UIApplication *)application shouldRestoreApplicationState:(NSCoder *)coder{ 112 | return YES; 113 | } 114 | 115 | 116 | - (UIViewController *)application:(UIApplication *)application viewControllerWithRestorationIdentifierPath:(NSArray *)identifierComponents coder:(NSCoder *)coder 117 | { 118 | NSString * key = [identifierComponents lastObject]; 119 | if([key isEqualToString:@"MMDrawer"]){ 120 | return self.window.rootViewController; 121 | } 122 | else if ([key isEqualToString:@"MMExampleCenterNavigationControllerRestorationKey"]) { 123 | return ((MMDrawerController *)self.window.rootViewController).centerViewController; 124 | } 125 | else if ([key isEqualToString:@"MMExampleRightNavigationControllerRestorationKey"]) { 126 | return ((MMDrawerController *)self.window.rootViewController).rightDrawerViewController; 127 | } 128 | else if ([key isEqualToString:@"MMExampleLeftNavigationControllerRestorationKey"]) { 129 | return ((MMDrawerController *)self.window.rootViewController).leftDrawerViewController; 130 | } 131 | else if ([key isEqualToString:@"MMExampleLeftSideDrawerController"]){ 132 | UIViewController * leftVC = ((MMDrawerController *)self.window.rootViewController).leftDrawerViewController; 133 | if([leftVC isKindOfClass:[UINavigationController class]]){ 134 | return [(UINavigationController*)leftVC topViewController]; 135 | } 136 | else { 137 | return leftVC; 138 | } 139 | 140 | } 141 | else if ([key isEqualToString:@"MMExampleRightSideDrawerController"]){ 142 | UIViewController * rightVC = ((MMDrawerController *)self.window.rootViewController).rightDrawerViewController; 143 | if([rightVC isKindOfClass:[UINavigationController class]]){ 144 | return [(UINavigationController*)rightVC topViewController]; 145 | } 146 | else { 147 | return rightVC; 148 | } 149 | } 150 | return nil; 151 | } 152 | 153 | @end 154 | -------------------------------------------------------------------------------- /KitchenSink/ExampleFiles/MMCenterTableViewCell.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2013 Mutual Mobile (http://mutualmobile.com/) 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a copy 4 | // of this software and associated documentation files (the "Software"), to deal 5 | // in the Software without restriction, including without limitation the rights 6 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | // copies of the Software, and to permit persons to whom the Software is 8 | // furnished to do so, subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included in 11 | // all copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | // THE SOFTWARE. 20 | 21 | 22 | #import "MMTableViewCell.h" 23 | 24 | @interface MMCenterTableViewCell : MMTableViewCell 25 | 26 | @end 27 | -------------------------------------------------------------------------------- /KitchenSink/ExampleFiles/MMCenterTableViewCell.m: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2013 Mutual Mobile (http://mutualmobile.com/) 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a copy 4 | // of this software and associated documentation files (the "Software"), to deal 5 | // in the Software without restriction, including without limitation the rights 6 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | // copies of the Software, and to permit persons to whom the Software is 8 | // furnished to do so, subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included in 11 | // all copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | // THE SOFTWARE. 20 | 21 | 22 | #import "MMCenterTableViewCell.h" 23 | 24 | @implementation MMCenterTableViewCell 25 | 26 | - (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier 27 | { 28 | self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]; 29 | if (self) { 30 | [self setAccessoryCheckmarkColor:[UIColor colorWithRed:13.0/255.0 31 | green:88.0/255.0 32 | blue:161.0/255.0 33 | alpha:1.0]]; 34 | } 35 | return self; 36 | } 37 | 38 | -(void)updateContentForNewContentSize{ 39 | if([[UIFont class] respondsToSelector:@selector(preferredFontForTextStyle:)]){ 40 | [self.textLabel setFont:[UIFont preferredFontForTextStyle:UIFontTextStyleBody]]; 41 | } 42 | } 43 | @end 44 | -------------------------------------------------------------------------------- /KitchenSink/ExampleFiles/MMDrawerControllerKitchenSink-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleDisplayName 8 | MMDrawer 9 | CFBundleExecutable 10 | ${EXECUTABLE_NAME} 11 | CFBundleIconFiles 12 | 13 | Icon.png 14 | Icon@2x.png 15 | Icon-72.png 16 | Icon-72@2x.png 17 | 18 | CFBundleIdentifier 19 | com.mutualmobile.mmsdcvc.${PRODUCT_NAME:rfc1034identifier} 20 | CFBundleInfoDictionaryVersion 21 | 6.0 22 | CFBundleName 23 | ${PRODUCT_NAME} 24 | CFBundlePackageType 25 | APPL 26 | CFBundleShortVersionString 27 | 1.0.0 28 | CFBundleSignature 29 | ???? 30 | CFBundleVersion 31 | 1.0.0 32 | LSRequiresIPhoneOS 33 | 34 | UILaunchStoryboardName 35 | LaunchScreen 36 | UIPrerenderedIcon 37 | 38 | UIRequiredDeviceCapabilities 39 | 40 | armv7 41 | 42 | UIStatusBarStyle 43 | UIStatusBarStyleBlackOpaque 44 | UISupportedInterfaceOrientations 45 | 46 | UIInterfaceOrientationPortrait 47 | UIInterfaceOrientationLandscapeLeft 48 | UIInterfaceOrientationLandscapeRight 49 | 50 | UISupportedInterfaceOrientations~ipad 51 | 52 | UIInterfaceOrientationPortrait 53 | UIInterfaceOrientationPortraitUpsideDown 54 | UIInterfaceOrientationLandscapeLeft 55 | UIInterfaceOrientationLandscapeRight 56 | 57 | UIViewControllerBasedStatusAppearance 58 | 59 | 60 | 61 | -------------------------------------------------------------------------------- /KitchenSink/ExampleFiles/MMDrawerControllerKitchenSink-Prefix.pch: -------------------------------------------------------------------------------- 1 | // 2 | // Prefix header for all source files of the 'MMDrawerController' target in the 'MMDrawerController' project 3 | // 4 | 5 | #import 6 | 7 | #ifndef __IPHONE_3_0 8 | #warning "This project uses features only available in iOS SDK 3.0 and later." 9 | #endif 10 | 11 | #ifdef __OBJC__ 12 | #import 13 | #import 14 | #endif -------------------------------------------------------------------------------- /KitchenSink/ExampleFiles/MMExampleCenterTableViewController.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2013 Mutual Mobile (http://mutualmobile.com/) 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a copy 4 | // of this software and associated documentation files (the "Software"), to deal 5 | // in the Software without restriction, including without limitation the rights 6 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | // copies of the Software, and to permit persons to whom the Software is 8 | // furnished to do so, subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included in 11 | // all copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | // THE SOFTWARE. 20 | 21 | 22 | #import 23 | #import "MMExampleViewController.h" 24 | /** 25 | 中部 控制器 26 | */ 27 | @interface MMExampleCenterTableViewController : MMExampleViewController 28 | @property (nonatomic,strong) UITableView * tableView; 29 | 30 | @end 31 | -------------------------------------------------------------------------------- /KitchenSink/ExampleFiles/MMExampleCenterTableViewController.m: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2013 Mutual Mobile (http://mutualmobile.com/) 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a copy 4 | // of this software and associated documentation files (the "Software"), to deal 5 | // in the Software without restriction, including without limitation the rights 6 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | // copies of the Software, and to permit persons to whom the Software is 8 | // furnished to do so, subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included in 11 | // all copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | // THE SOFTWARE. 20 | 21 | 22 | #import "MMExampleCenterTableViewController.h" 23 | #import "MMExampleDrawerVisualStateManager.h" 24 | #import "UIViewController+MMDrawerController.h" 25 | #import "MMDrawerBarButtonItem.h" 26 | #import "MMLogoView.h" 27 | #import "MMCenterTableViewCell.h" 28 | #import "MMExampleLeftSideDrawerViewController.h" 29 | #import "MMExampleRightSideDrawerViewController.h" 30 | #import "MMNavigationController.h" 31 | 32 | #import 33 | 34 | typedef NS_ENUM(NSInteger, MMCenterViewControllerSection){ 35 | /// 左边控制器 是否可用 36 | MMCenterViewControllerSectionLeftViewState, 37 | /// 左边 控制器可选择的动画效果 38 | MMCenterViewControllerSectionLeftDrawerAnimation, 39 | /// 右边 控制器 是否可用 40 | MMCenterViewControllerSectionRightViewState, 41 | /// 右边 控制器可选择的动画效果 42 | MMCenterViewControllerSectionRightDrawerAnimation, 43 | }; 44 | 45 | @interface MMExampleCenterTableViewController () 46 | 47 | @end 48 | 49 | @implementation MMExampleCenterTableViewController 50 | 51 | - (id)init 52 | { 53 | self = [super init]; 54 | if (self) { 55 | [self setRestorationIdentifier:@"MMExampleCenterControllerRestorationKey"]; 56 | } 57 | return self; 58 | } 59 | 60 | - (void)viewDidLoad 61 | { 62 | [super viewDidLoad]; 63 | 64 | _tableView = [[UITableView alloc] initWithFrame:self.view.bounds style:UITableViewStyleGrouped]; 65 | [self.tableView setDelegate:self]; 66 | [self.tableView setDataSource:self]; 67 | [self.view addSubview:self.tableView]; 68 | [self.tableView setAutoresizingMask:UIViewAutoresizingFlexibleWidth|UIViewAutoresizingFlexibleHeight]; 69 | 70 | 71 | //// 双击 弹跳 出 左边 抽屉 40 点 的距离 然后 再 弹 回去 72 | UITapGestureRecognizer * doubleTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(doubleTap:)]; 73 | [doubleTap setNumberOfTapsRequired:2]; 74 | [self.view addGestureRecognizer:doubleTap]; 75 | 76 | 77 | //// 双指 双击 弹出 右边 抽屉 40 点 的距离 然后 再 弹回去 78 | UITapGestureRecognizer * twoFingerDoubleTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(twoFingerDoubleTap:)]; 79 | [twoFingerDoubleTap setNumberOfTapsRequired:2]; 80 | [twoFingerDoubleTap setNumberOfTouchesRequired:2]; 81 | [self.view addGestureRecognizer:twoFingerDoubleTap]; 82 | 83 | 84 | [self setupLeftMenuButton]; 85 | [self setupRightMenuButton]; 86 | 87 | UIColor * barColor = [UIColor 88 | colorWithRed:247.0/255.0 89 | green:249.0/255.0 90 | blue:250.0/255.0 91 | alpha:1.0]; 92 | [self.navigationController.navigationBar setBarTintColor:barColor]; 93 | 94 | 95 | MMLogoView * logo = [[MMLogoView alloc] initWithFrame:CGRectMake(0, 0, 29, 31)]; 96 | [self.navigationItem setTitleView:logo]; 97 | [self.navigationController.view.layer setCornerRadius:10.0f]; 98 | 99 | 100 | UIView *backView = [[UIView alloc] init]; 101 | [backView setBackgroundColor:[UIColor colorWithRed:208.0/255.0 102 | green:208.0/255.0 103 | blue:208.0/255.0 104 | alpha:1.0]]; 105 | [self.tableView setBackgroundView:backView]; 106 | } 107 | 108 | -(void)viewWillAppear:(BOOL)animated{ 109 | [super viewWillAppear:animated]; 110 | NSLog(@"Center will appear"); 111 | } 112 | 113 | -(void)viewDidAppear:(BOOL)animated{ 114 | [super viewDidAppear:animated]; 115 | NSLog(@"Center did appear"); 116 | } 117 | 118 | -(void)viewWillDisappear:(BOOL)animated{ 119 | [super viewWillDisappear:animated]; 120 | NSLog(@"Center will disappear"); 121 | } 122 | 123 | -(void)viewDidDisappear:(BOOL)animated{ 124 | [super viewDidDisappear:animated]; 125 | NSLog(@"Center did disappear"); 126 | } 127 | 128 | -(void)setupLeftMenuButton{ 129 | MMDrawerBarButtonItem * leftDrawerButton = [[MMDrawerBarButtonItem alloc] initWithTarget:self action:@selector(leftDrawerButtonPress:)]; 130 | [self.navigationItem setLeftBarButtonItem:leftDrawerButton animated:YES]; 131 | } 132 | 133 | -(void)setupRightMenuButton{ 134 | MMDrawerBarButtonItem * rightDrawerButton = [[MMDrawerBarButtonItem alloc] initWithTarget:self action:@selector(rightDrawerButtonPress:)]; 135 | [self.navigationItem setRightBarButtonItem:rightDrawerButton animated:YES]; 136 | } 137 | 138 | -(void)contentSizeDidChange:(NSString *)size{ 139 | [self.tableView reloadData]; 140 | } 141 | 142 | #pragma mark - Table view data source 143 | 144 | - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView 145 | { 146 | return 4; 147 | } 148 | 149 | - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section 150 | { 151 | // Return the number of rows in the section. 152 | switch (section) { 153 | case MMCenterViewControllerSectionLeftDrawerAnimation: 154 | case MMCenterViewControllerSectionRightDrawerAnimation: 155 | return 5; 156 | case MMCenterViewControllerSectionLeftViewState: 157 | case MMCenterViewControllerSectionRightViewState: 158 | return 1; 159 | default: 160 | return 0; 161 | } 162 | } 163 | 164 | - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 165 | { 166 | static NSString *CellIdentifier = @"Cell"; 167 | 168 | UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; 169 | if (cell == nil) { 170 | 171 | cell = [[MMCenterTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier]; 172 | [cell setSelectionStyle:UITableViewCellSelectionStyleGray]; 173 | } 174 | 175 | UIColor * selectedColor = [UIColor 176 | colorWithRed:1.0/255.0 177 | green:15.0/255.0 178 | blue:25.0/255.0 179 | alpha:1.0]; 180 | UIColor * unselectedColor = [UIColor 181 | colorWithRed:79.0/255.0 182 | green:93.0/255.0 183 | blue:102.0/255.0 184 | alpha:1.0]; 185 | 186 | switch (indexPath.section) { 187 | case MMCenterViewControllerSectionLeftDrawerAnimation: 188 | case MMCenterViewControllerSectionRightDrawerAnimation:{ 189 | MMDrawerAnimationType animationTypeForSection; 190 | //left 控制器 动画效果 191 | if(indexPath.section == MMCenterViewControllerSectionLeftDrawerAnimation){ 192 | animationTypeForSection = [[MMExampleDrawerVisualStateManager sharedManager] leftDrawerAnimationType]; 193 | } 194 | //right 控制器 动画效果 195 | else { 196 | animationTypeForSection = [[MMExampleDrawerVisualStateManager sharedManager] rightDrawerAnimationType]; 197 | } 198 | 199 | //right and left 此时的动画效果 cell 表现形式 200 | if(animationTypeForSection == indexPath.row){ 201 | [cell setAccessoryType:UITableViewCellAccessoryCheckmark]; 202 | [cell.textLabel setTextColor:selectedColor]; 203 | } 204 | // right and left 可选择的其他动画效果 cell 表现形式 205 | else { 206 | [cell setAccessoryType:UITableViewCellAccessoryNone]; 207 | [cell.textLabel setTextColor:unselectedColor]; 208 | } 209 | //所有动画 名字 在tableview 中的显示 210 | switch (indexPath.row) { 211 | case MMDrawerAnimationTypeNone: 212 | [cell.textLabel setText:@"None"]; 213 | break; 214 | case MMDrawerAnimationTypeSlide: 215 | [cell.textLabel setText:@"Slide"]; 216 | break; 217 | case MMDrawerAnimationTypeSlideAndScale: 218 | [cell.textLabel setText:@"Slide and Scale"]; 219 | break; 220 | case MMDrawerAnimationTypeSwingingDoor: 221 | [cell.textLabel setText:@"Swinging Door"]; 222 | break; 223 | case MMDrawerAnimationTypeParallax: 224 | [cell.textLabel setText:@"Parallax"]; 225 | break; 226 | default: 227 | break; 228 | } 229 | break; 230 | } 231 | case MMCenterViewControllerSectionLeftViewState:{ 232 | [cell.textLabel setText:@"Enabled"]; 233 | //是否有 left 控制器 234 | if(self.mm_drawerController.leftDrawerViewController){ 235 | [cell setAccessoryType:UITableViewCellAccessoryCheckmark]; 236 | [cell.textLabel setTextColor:selectedColor]; 237 | } 238 | else{ 239 | [cell setAccessoryType:UITableViewCellAccessoryNone]; 240 | [cell.textLabel setTextColor:unselectedColor]; 241 | } 242 | break; 243 | } 244 | case MMCenterViewControllerSectionRightViewState:{ 245 | [cell.textLabel setText:@"Enabled"]; 246 | //是否 有 right 控制器 247 | if(self.mm_drawerController.rightDrawerViewController){ 248 | [cell setAccessoryType:UITableViewCellAccessoryCheckmark]; 249 | [cell.textLabel setTextColor:selectedColor]; 250 | } 251 | else{ 252 | [cell setAccessoryType:UITableViewCellAccessoryNone]; 253 | [cell.textLabel setTextColor:unselectedColor]; 254 | } 255 | break; 256 | } 257 | default: 258 | break; 259 | } 260 | 261 | return cell; 262 | } 263 | 264 | -(NSString*)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section{ 265 | // tableview sectionHeader 标题 266 | switch (section) { 267 | case MMCenterViewControllerSectionLeftDrawerAnimation: 268 | return @"Left Drawer Animation"; 269 | case MMCenterViewControllerSectionRightDrawerAnimation: 270 | return @"Right Drawer Animation"; 271 | case MMCenterViewControllerSectionLeftViewState: 272 | return @"Left Drawer"; 273 | case MMCenterViewControllerSectionRightViewState: 274 | return @"Right Drawer"; 275 | default: 276 | return nil; 277 | } 278 | } 279 | #pragma mark - Table view delegate 280 | /// 点击cell 事件 281 | - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath 282 | { 283 | switch (indexPath.section) { 284 | 285 | //动画效果选择 286 | case MMCenterViewControllerSectionLeftDrawerAnimation: 287 | case MMCenterViewControllerSectionRightDrawerAnimation:{ 288 | if(indexPath.section == MMCenterViewControllerSectionLeftDrawerAnimation){ 289 | [[MMExampleDrawerVisualStateManager sharedManager] setLeftDrawerAnimationType:indexPath.row]; 290 | } 291 | else { 292 | [[MMExampleDrawerVisualStateManager sharedManager] setRightDrawerAnimationType:indexPath.row]; 293 | } 294 | //刷新 section 295 | [tableView reloadSections:[NSIndexSet indexSetWithIndex:indexPath.section] withRowAnimation:UITableViewRowAnimationNone]; 296 | //代码的方式选中 cell 297 | [tableView selectRowAtIndexPath:indexPath animated:NO scrollPosition:UITableViewScrollPositionNone]; 298 | //反选效果 299 | [tableView deselectRowAtIndexPath:indexPath animated:YES]; 300 | break; 301 | } 302 | //左右 控制器 是否显示 303 | case MMCenterViewControllerSectionLeftViewState: 304 | case MMCenterViewControllerSectionRightViewState:{ 305 | UIViewController * sideDrawerViewController; 306 | MMDrawerSide drawerSide = MMDrawerSideNone; 307 | if(indexPath.section == MMCenterViewControllerSectionLeftViewState){ 308 | //左边抽屉 309 | sideDrawerViewController = self.mm_drawerController.leftDrawerViewController; 310 | drawerSide = MMDrawerSideLeft; 311 | } 312 | else if(indexPath.section == MMCenterViewControllerSectionRightViewState){ 313 | //右边抽屉 314 | sideDrawerViewController = self.mm_drawerController.rightDrawerViewController; 315 | drawerSide = MMDrawerSideRight; 316 | } 317 | 318 | if(sideDrawerViewController){ 319 | [self.mm_drawerController 320 | closeDrawerAnimated:YES 321 | completion:^(BOOL finished) { 322 | if(drawerSide == MMDrawerSideLeft){ 323 | //左边抽屉 置 nil 324 | [self.mm_drawerController setLeftDrawerViewController:nil]; 325 | //导航栏 左边 按钮 置 nil 326 | [self.navigationItem setLeftBarButtonItems:nil animated:YES]; 327 | } 328 | else if(drawerSide == MMDrawerSideRight){ 329 | //右边抽屉 置 nil 330 | [self.mm_drawerController setRightDrawerViewController:nil]; 331 | //导航栏 右边 按钮 置 nil 332 | [self.navigationItem setRightBarButtonItem:nil animated:YES]; 333 | } 334 | 335 | /// 刷新 cell 336 | [tableView reloadRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationNone]; 337 | /// cell 选中效果 338 | [tableView selectRowAtIndexPath:indexPath animated:NO scrollPosition:UITableViewScrollPositionNone]; 339 | /// 反选 效果 340 | [tableView deselectRowAtIndexPath:indexPath animated:YES]; 341 | }]; 342 | 343 | } 344 | else { 345 | if(drawerSide == MMDrawerSideLeft){ 346 | /// 添加 左边 抽屉控制器 347 | UIViewController * vc = [[MMExampleLeftSideDrawerViewController alloc] init]; 348 | UINavigationController * navC = [[MMNavigationController alloc] initWithRootViewController:vc]; 349 | [self.mm_drawerController setLeftDrawerViewController:navC]; 350 | [self setupLeftMenuButton]; 351 | 352 | } 353 | else if(drawerSide == MMDrawerSideRight){ 354 | /// 添加 右边 控制器 355 | UIViewController * vc = [[MMExampleRightSideDrawerViewController alloc] init]; 356 | UINavigationController * navC = [[MMNavigationController alloc] initWithRootViewController:vc]; 357 | [self.mm_drawerController setRightDrawerViewController:navC]; 358 | [self setupRightMenuButton]; 359 | } 360 | 361 | /// 刷新 cell 362 | [tableView reloadRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationNone]; 363 | /// 代码 选择 cell 效果 364 | [tableView selectRowAtIndexPath:indexPath animated:NO scrollPosition:UITableViewScrollPositionNone]; 365 | /// 反选择 效果 366 | [tableView deselectRowAtIndexPath:indexPath animated:YES]; 367 | } 368 | 369 | break; 370 | } 371 | default: 372 | break; 373 | } 374 | } 375 | 376 | #pragma mark - Button Handlers 按钮事件 377 | 378 | //切换 到 左边 抽屉 379 | -(void)leftDrawerButtonPress:(id)sender{ 380 | [self.mm_drawerController toggleDrawerSide:MMDrawerSideLeft animated:YES completion:nil]; 381 | } 382 | // 切换到 右边抽屉 383 | -(void)rightDrawerButtonPress:(id)sender{ 384 | [self.mm_drawerController toggleDrawerSide:MMDrawerSideRight animated:YES completion:nil]; 385 | } 386 | 387 | // 双击 弹跳 出 左边 抽屉 40 点 的距离 然后 再 弹 回去 388 | -(void)doubleTap:(UITapGestureRecognizer*)gesture{ 389 | [self.mm_drawerController bouncePreviewForDrawerSide:MMDrawerSideLeft completion:nil]; 390 | } 391 | 392 | // 双指 双击 弹出 右边 抽屉 40 点 的距离 然后 再 弹回去 393 | -(void)twoFingerDoubleTap:(UITapGestureRecognizer*)gesture{ 394 | [self.mm_drawerController bouncePreviewForDrawerSide:MMDrawerSideRight completion:nil]; 395 | } 396 | 397 | @end 398 | -------------------------------------------------------------------------------- /KitchenSink/ExampleFiles/MMExampleDrawerVisualStateManager.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2013 Mutual Mobile (http://mutualmobile.com/) 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a copy 4 | // of this software and associated documentation files (the "Software"), to deal 5 | // in the Software without restriction, including without limitation the rights 6 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | // copies of the Software, and to permit persons to whom the Software is 8 | // furnished to do so, subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included in 11 | // all copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | // THE SOFTWARE. 20 | 21 | 22 | #import 23 | #import "MMDrawerVisualState.h" 24 | 25 | //动画效果 26 | typedef NS_ENUM(NSInteger, MMDrawerAnimationType){ 27 | MMDrawerAnimationTypeNone,//无 特效 28 | MMDrawerAnimationTypeSlide,// 滑动效果 29 | MMDrawerAnimationTypeSlideAndScale,// 滑动 和 变形 效果 30 | MMDrawerAnimationTypeSwingingDoor,//开门效果 31 | MMDrawerAnimationTypeParallax,//视差 动画 32 | }; 33 | 34 | @interface MMExampleDrawerVisualStateManager : NSObject 35 | 36 | @property (nonatomic,assign) MMDrawerAnimationType leftDrawerAnimationType; 37 | @property (nonatomic,assign) MMDrawerAnimationType rightDrawerAnimationType; 38 | 39 | + (MMExampleDrawerVisualStateManager *)sharedManager; 40 | 41 | 42 | /** 43 | 左边/右边 控制器 view 的变化效果 44 | */ 45 | -(MMDrawerControllerDrawerVisualStateBlock)drawerVisualStateBlockForDrawerSide:(MMDrawerSide)drawerSide; 46 | 47 | @end 48 | -------------------------------------------------------------------------------- /KitchenSink/ExampleFiles/MMExampleDrawerVisualStateManager.m: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2013 Mutual Mobile (http://mutualmobile.com/) 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a copy 4 | // of this software and associated documentation files (the "Software"), to deal 5 | // in the Software without restriction, including without limitation the rights 6 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | // copies of the Software, and to permit persons to whom the Software is 8 | // furnished to do so, subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included in 11 | // all copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | // THE SOFTWARE. 20 | 21 | 22 | #import "MMExampleDrawerVisualStateManager.h" 23 | 24 | #import 25 | 26 | @implementation MMExampleDrawerVisualStateManager 27 | 28 | + (MMExampleDrawerVisualStateManager *)sharedManager { 29 | static MMExampleDrawerVisualStateManager *_sharedManager = nil; 30 | static dispatch_once_t onceToken; 31 | dispatch_once(&onceToken, ^{ 32 | _sharedManager = [[MMExampleDrawerVisualStateManager alloc] init]; 33 | [_sharedManager setLeftDrawerAnimationType:MMDrawerAnimationTypeParallax]; 34 | [_sharedManager setRightDrawerAnimationType:MMDrawerAnimationTypeParallax]; 35 | }); 36 | 37 | return _sharedManager; 38 | } 39 | 40 | -(MMDrawerControllerDrawerVisualStateBlock)drawerVisualStateBlockForDrawerSide:(MMDrawerSide)drawerSide{ 41 | 42 | MMDrawerAnimationType animationType; 43 | if(drawerSide == MMDrawerSideLeft){ 44 | animationType = self.leftDrawerAnimationType; 45 | } 46 | else { 47 | animationType = self.rightDrawerAnimationType; 48 | } 49 | 50 | MMDrawerControllerDrawerVisualStateBlock visualStateBlock = nil; 51 | switch (animationType) { 52 | case MMDrawerAnimationTypeSlide: 53 | visualStateBlock = [MMDrawerVisualState slideVisualStateBlock]; 54 | break; 55 | case MMDrawerAnimationTypeSlideAndScale: 56 | visualStateBlock = [MMDrawerVisualState slideAndScaleVisualStateBlock]; 57 | break; 58 | case MMDrawerAnimationTypeParallax: 59 | visualStateBlock = [MMDrawerVisualState parallaxVisualStateBlockWithParallaxFactor:2.0]; 60 | break; 61 | case MMDrawerAnimationTypeSwingingDoor: 62 | visualStateBlock = [MMDrawerVisualState swingingDoorVisualStateBlock]; 63 | break; 64 | default: 65 | visualStateBlock = ^(MMDrawerController * drawerController, MMDrawerSide drawerSide, CGFloat percentVisible){ 66 | 67 | UIViewController * sideDrawerViewController; 68 | CATransform3D transform; 69 | CGFloat maxDrawerWidth; 70 | 71 | if(drawerSide == MMDrawerSideLeft){ 72 | sideDrawerViewController = drawerController.leftDrawerViewController; 73 | maxDrawerWidth = drawerController.maximumLeftDrawerWidth; 74 | } 75 | else if(drawerSide == MMDrawerSideRight){ 76 | sideDrawerViewController = drawerController.rightDrawerViewController; 77 | maxDrawerWidth = drawerController.maximumRightDrawerWidth; 78 | } 79 | 80 | if(percentVisible > 1.0){ 81 | transform = CATransform3DMakeScale(percentVisible, 1.f, 1.f); 82 | 83 | if(drawerSide == MMDrawerSideLeft){ 84 | transform = CATransform3DTranslate(transform, maxDrawerWidth*(percentVisible-1.f)/2, 0.f, 0.f); 85 | }else if(drawerSide == MMDrawerSideRight){ 86 | transform = CATransform3DTranslate(transform, -maxDrawerWidth*(percentVisible-1.f)/2, 0.f, 0.f); 87 | } 88 | } 89 | else { 90 | transform = CATransform3DIdentity; 91 | } 92 | [sideDrawerViewController.view.layer setTransform:transform]; 93 | }; 94 | break; 95 | } 96 | return visualStateBlock; 97 | } 98 | @end 99 | -------------------------------------------------------------------------------- /KitchenSink/ExampleFiles/MMExampleLeftSideDrawerViewController.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2013 Mutual Mobile (http://mutualmobile.com/) 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a copy 4 | // of this software and associated documentation files (the "Software"), to deal 5 | // in the Software without restriction, including without limitation the rights 6 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | // copies of the Software, and to permit persons to whom the Software is 8 | // furnished to do so, subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included in 11 | // all copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | // THE SOFTWARE. 20 | 21 | 22 | #import "MMExampleSideDrawerViewController.h" 23 | /** 24 | 左边 控制器 25 | */ 26 | @interface MMExampleLeftSideDrawerViewController : MMExampleSideDrawerViewController 27 | 28 | @end 29 | -------------------------------------------------------------------------------- /KitchenSink/ExampleFiles/MMExampleLeftSideDrawerViewController.m: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2013 Mutual Mobile (http://mutualmobile.com/) 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a copy 4 | // of this software and associated documentation files (the "Software"), to deal 5 | // in the Software without restriction, including without limitation the rights 6 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | // copies of the Software, and to permit persons to whom the Software is 8 | // furnished to do so, subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included in 11 | // all copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | // THE SOFTWARE. 20 | 21 | 22 | #import "MMExampleLeftSideDrawerViewController.h" 23 | #import "MMTableViewCell.h" 24 | 25 | @interface MMExampleLeftSideDrawerViewController () 26 | 27 | @end 28 | 29 | @implementation MMExampleLeftSideDrawerViewController 30 | 31 | -(id)init{ 32 | self = [super init]; 33 | if(self){ 34 | [self setRestorationIdentifier:@"MMExampleLeftSideDrawerController"]; 35 | } 36 | return self; 37 | } 38 | 39 | -(void)viewWillAppear:(BOOL)animated{ 40 | [super viewWillAppear:animated]; 41 | NSLog(@"Left will appear"); 42 | } 43 | 44 | -(void)viewDidAppear:(BOOL)animated{ 45 | [super viewDidAppear:animated]; 46 | NSLog(@"Left did appear"); 47 | } 48 | 49 | -(void)viewWillDisappear:(BOOL)animated{ 50 | [super viewWillDisappear:animated]; 51 | NSLog(@"Left will disappear"); 52 | } 53 | 54 | -(void)viewDidDisappear:(BOOL)animated{ 55 | [super viewDidDisappear:animated]; 56 | NSLog(@"Left did disappear"); 57 | } 58 | 59 | -(void)viewDidLoad{ 60 | [super viewDidLoad]; 61 | [self setTitle:@"Left Drawer"]; 62 | } 63 | 64 | -(NSString*)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section{ 65 | 66 | if(section == MMDrawerSectionDrawerWidth) 67 | return @"Left Drawer Width"; 68 | else 69 | return [super tableView:tableView titleForHeaderInSection:section]; 70 | } 71 | 72 | -(UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{ 73 | UITableViewCell * cell = [super tableView:tableView cellForRowAtIndexPath:indexPath]; 74 | if(indexPath.section == MMDrawerSectionDrawerWidth){ 75 | 76 | CGFloat width = [self.drawerWidths[indexPath.row] intValue]; 77 | CGFloat drawerWidth = self.mm_drawerController.maximumLeftDrawerWidth; 78 | if(drawerWidth == width){ 79 | [cell setAccessoryType:UITableViewCellAccessoryCheckmark]; 80 | } 81 | else{ 82 | [cell setAccessoryType:UITableViewCellAccessoryNone]; 83 | } 84 | [cell.textLabel setText:[NSString stringWithFormat:@"Width %d",[self.drawerWidths[indexPath.row] intValue]]]; 85 | } 86 | return cell; 87 | } 88 | 89 | -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{ 90 | if(indexPath.section == MMDrawerSectionDrawerWidth){ 91 | [self.mm_drawerController 92 | setMaximumLeftDrawerWidth:[self.drawerWidths[indexPath.row] floatValue] 93 | animated:YES 94 | completion:^(BOOL finished) { 95 | [tableView reloadSections:[NSIndexSet indexSetWithIndex:indexPath.section] withRowAnimation:UITableViewRowAnimationNone]; 96 | [tableView selectRowAtIndexPath:indexPath animated:NO scrollPosition:UITableViewScrollPositionNone]; 97 | [tableView deselectRowAtIndexPath:indexPath animated:YES]; 98 | }]; 99 | 100 | } 101 | else { 102 | [super tableView:tableView didSelectRowAtIndexPath:indexPath]; 103 | } 104 | } 105 | 106 | @end 107 | -------------------------------------------------------------------------------- /KitchenSink/ExampleFiles/MMExampleRightSideDrawerViewController.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2013 Mutual Mobile (http://mutualmobile.com/) 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a copy 4 | // of this software and associated documentation files (the "Software"), to deal 5 | // in the Software without restriction, including without limitation the rights 6 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | // copies of the Software, and to permit persons to whom the Software is 8 | // furnished to do so, subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included in 11 | // all copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | // THE SOFTWARE. 20 | 21 | #import "MMExampleSideDrawerViewController.h" 22 | /** 23 | 右边 控制器 24 | */ 25 | @interface MMExampleRightSideDrawerViewController : MMExampleSideDrawerViewController 26 | 27 | @end 28 | -------------------------------------------------------------------------------- /KitchenSink/ExampleFiles/MMExampleRightSideDrawerViewController.m: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2013 Mutual Mobile (http://mutualmobile.com/) 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a copy 4 | // of this software and associated documentation files (the "Software"), to deal 5 | // in the Software without restriction, including without limitation the rights 6 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | // copies of the Software, and to permit persons to whom the Software is 8 | // furnished to do so, subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included in 11 | // all copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | // THE SOFTWARE. 20 | 21 | 22 | #import "MMExampleRightSideDrawerViewController.h" 23 | 24 | @interface MMExampleRightSideDrawerViewController () 25 | 26 | @end 27 | 28 | @implementation MMExampleRightSideDrawerViewController 29 | -(id)init{ 30 | self = [super init]; 31 | if(self){ 32 | [self setRestorationIdentifier:@"MMExampleRightSideDrawerController"]; 33 | } 34 | return self; 35 | } 36 | 37 | -(void)viewWillAppear:(BOOL)animated{ 38 | [super viewWillAppear:animated]; 39 | NSLog(@"Right will appear"); 40 | } 41 | 42 | -(void)viewDidAppear:(BOOL)animated{ 43 | [super viewDidAppear:animated]; 44 | NSLog(@"Right did appear"); 45 | } 46 | 47 | -(void)viewWillDisappear:(BOOL)animated{ 48 | [super viewWillDisappear:animated]; 49 | NSLog(@"Right will disappear"); 50 | } 51 | 52 | -(void)viewDidDisappear:(BOOL)animated{ 53 | [super viewDidDisappear:animated]; 54 | NSLog(@"Right did disappear"); 55 | } 56 | 57 | -(void)viewDidLoad{ 58 | [super viewDidLoad]; 59 | [self setTitle:@"Right Drawer"]; 60 | } 61 | 62 | -(NSString*)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section{ 63 | 64 | if(section == MMDrawerSectionDrawerWidth) 65 | return @"Right Drawer Width"; 66 | else 67 | return [super tableView:tableView titleForHeaderInSection:section]; 68 | } 69 | 70 | -(UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{ 71 | UITableViewCell * cell = [super tableView:tableView cellForRowAtIndexPath:indexPath]; 72 | if(indexPath.section == MMDrawerSectionDrawerWidth){ 73 | CGFloat width = [self.drawerWidths[indexPath.row] intValue]; 74 | CGFloat drawerWidth = self.mm_drawerController.maximumRightDrawerWidth; 75 | if(drawerWidth == width) 76 | [cell setAccessoryType:UITableViewCellAccessoryCheckmark]; 77 | else 78 | [cell setAccessoryType:UITableViewCellAccessoryNone]; 79 | [cell.textLabel setText:[NSString stringWithFormat:@"Width %d",[self.drawerWidths[indexPath.row] intValue]]]; 80 | } 81 | 82 | return cell; 83 | } 84 | 85 | -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{ 86 | if(indexPath.section == MMDrawerSectionDrawerWidth){ 87 | [self.mm_drawerController 88 | setMaximumRightDrawerWidth:[self.drawerWidths[indexPath.row] floatValue] 89 | animated:YES 90 | completion:^(BOOL finished) { 91 | [tableView reloadSections:[NSIndexSet indexSetWithIndex:indexPath.section] withRowAnimation:UITableViewRowAnimationNone]; 92 | [tableView selectRowAtIndexPath:indexPath animated:NO scrollPosition:UITableViewScrollPositionNone]; 93 | [tableView deselectRowAtIndexPath:indexPath animated:YES]; 94 | }]; 95 | } 96 | else { 97 | [super tableView:tableView didSelectRowAtIndexPath:indexPath]; 98 | } 99 | } 100 | 101 | @end 102 | -------------------------------------------------------------------------------- /KitchenSink/ExampleFiles/MMExampleSideDrawerViewController.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2013 Mutual Mobile (http://mutualmobile.com/) 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a copy 4 | // of this software and associated documentation files (the "Software"), to deal 5 | // in the Software without restriction, including without limitation the rights 6 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | // copies of the Software, and to permit persons to whom the Software is 8 | // furnished to do so, subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included in 11 | // all copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | // THE SOFTWARE. 20 | 21 | 22 | #import 23 | #import "UIViewController+MMDrawerController.h" 24 | #import "MMExampleViewController.h" 25 | 26 | typedef NS_ENUM(NSInteger, MMDrawerSection){ 27 | MMDrawerSectionViewSelection, 28 | MMDrawerSectionDrawerWidth, 29 | MMDrawerSectionShadowToggle, 30 | MMDrawerSectionOpenDrawerGestures, 31 | MMDrawerSectionCloseDrawerGestures, 32 | MMDrawerSectionCenterHiddenInteraction, 33 | MMDrawerSectionStretchDrawer, 34 | }; 35 | 36 | @interface MMExampleSideDrawerViewController : MMExampleViewController 37 | @property (nonatomic, strong) UITableView * tableView; 38 | @property (nonatomic,strong) NSArray * drawerWidths; 39 | 40 | @end 41 | -------------------------------------------------------------------------------- /KitchenSink/ExampleFiles/MMExampleSideDrawerViewController.m: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2013 Mutual Mobile (http://mutualmobile.com/) 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a copy 4 | // of this software and associated documentation files (the "Software"), to deal 5 | // in the Software without restriction, including without limitation the rights 6 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | // copies of the Software, and to permit persons to whom the Software is 8 | // furnished to do so, subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included in 11 | // all copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | // THE SOFTWARE. 20 | 21 | 22 | #import "MMExampleSideDrawerViewController.h" 23 | #import "MMExampleCenterTableViewController.h" 24 | #import "MMSideDrawerTableViewCell.h" 25 | #import "MMSideDrawerSectionHeaderView.h" 26 | #import "MMLogoView.h" 27 | #import "MMNavigationController.h" 28 | 29 | @implementation MMExampleSideDrawerViewController 30 | 31 | - (void)viewDidLoad 32 | { 33 | [super viewDidLoad]; 34 | 35 | _tableView = [[UITableView alloc] initWithFrame:self.view.bounds style:UITableViewStyleGrouped]; 36 | 37 | [self.tableView setDelegate:self]; 38 | [self.tableView setDataSource:self]; 39 | [self.view addSubview:self.tableView]; 40 | [self.tableView setAutoresizingMask:UIViewAutoresizingFlexibleWidth|UIViewAutoresizingFlexibleHeight]; 41 | 42 | UIColor * tableViewBackgroundColor; 43 | tableViewBackgroundColor = [UIColor colorWithRed:110.0/255.0 44 | green:113.0/255.0 45 | blue:115.0/255.0 46 | alpha:1.0]; 47 | [self.tableView setBackgroundColor:tableViewBackgroundColor]; 48 | 49 | [self.tableView setSeparatorStyle:UITableViewCellSeparatorStyleNone]; 50 | 51 | [self.view setBackgroundColor:[UIColor colorWithRed:66.0/255.0 52 | green:69.0/255.0 53 | blue:71.0/255.0 54 | alpha:1.0]]; 55 | 56 | UIColor * barColor = [UIColor colorWithRed:161.0/255.0 57 | green:164.0/255.0 58 | blue:166.0/255.0 59 | alpha:1.0]; 60 | if([self.navigationController.navigationBar respondsToSelector:@selector(setBarTintColor:)]){ 61 | [self.navigationController.navigationBar setBarTintColor:barColor]; 62 | } 63 | else { 64 | [self.navigationController.navigationBar setTintColor:barColor]; 65 | } 66 | 67 | 68 | NSDictionary *navBarTitleDict; 69 | UIColor * titleColor = [UIColor colorWithRed:55.0/255.0 70 | green:70.0/255.0 71 | blue:77.0/255.0 72 | alpha:1.0]; 73 | navBarTitleDict = @{NSForegroundColorAttributeName:titleColor}; 74 | [self.navigationController.navigationBar setTitleTextAttributes:navBarTitleDict]; 75 | 76 | self.drawerWidths = @[@(160),@(200),@(240),@(280),@(320)]; 77 | 78 | CGSize logoSize = CGSizeMake(58, 62); 79 | MMLogoView * logo = [[MMLogoView alloc] initWithFrame:CGRectMake(CGRectGetMidX(self.tableView.bounds)-logoSize.width/2.0, 80 | -logoSize.height-logoSize.height/4.0, 81 | logoSize.width, 82 | logoSize.height)]; 83 | [logo setAutoresizingMask:UIViewAutoresizingFlexibleLeftMargin|UIViewAutoresizingFlexibleRightMargin]; 84 | [self.tableView addSubview:logo]; 85 | [self.view setBackgroundColor:[UIColor clearColor]]; 86 | } 87 | 88 | -(void)viewWillAppear:(BOOL)animated{ 89 | [super viewWillAppear:animated]; 90 | [self.tableView reloadSections:[NSIndexSet indexSetWithIndexesInRange:NSMakeRange(0, self.tableView.numberOfSections-1)] withRowAnimation:UITableViewRowAnimationNone]; 91 | } 92 | 93 | - (void)didReceiveMemoryWarning 94 | { 95 | [super didReceiveMemoryWarning]; 96 | // Dispose of any resources that can be recreated. 97 | } 98 | 99 | -(void)contentSizeDidChange:(NSString *)size{ 100 | [self.tableView reloadData]; 101 | } 102 | 103 | #pragma mark - Table view data source 104 | 105 | - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView 106 | { 107 | // Return the number of sections. 108 | return 7; 109 | } 110 | 111 | - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section 112 | { 113 | // Return the number of rows in the section. 114 | switch (section) { 115 | case MMDrawerSectionViewSelection: 116 | return 2; 117 | case MMDrawerSectionDrawerWidth: 118 | return self.drawerWidths.count; 119 | case MMDrawerSectionShadowToggle: 120 | return 1; 121 | case MMDrawerSectionOpenDrawerGestures: 122 | return 3; 123 | case MMDrawerSectionCloseDrawerGestures: 124 | return 6; 125 | case MMDrawerSectionCenterHiddenInteraction: 126 | return 3; 127 | case MMDrawerSectionStretchDrawer: 128 | return 1; 129 | default: 130 | return 0; 131 | } 132 | } 133 | 134 | - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 135 | { 136 | static NSString *CellIdentifier = @"Cell"; 137 | 138 | UITableViewCell *cell = (UITableViewCell*)[tableView dequeueReusableCellWithIdentifier:CellIdentifier]; 139 | if (cell == nil) { 140 | 141 | cell = [[MMSideDrawerTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier]; 142 | [cell setSelectionStyle:UITableViewCellSelectionStyleBlue]; 143 | } 144 | 145 | switch (indexPath.section) { 146 | case MMDrawerSectionViewSelection: 147 | if(indexPath.row == 0){ 148 | [cell.textLabel setText:@"Quick View Change"]; 149 | } 150 | else { 151 | [cell.textLabel setText:@"Full View Change"]; 152 | } 153 | [cell setAccessoryType:UITableViewCellAccessoryDisclosureIndicator]; 154 | break; 155 | case MMDrawerSectionDrawerWidth:{ 156 | //Implement in Subclass 157 | break; 158 | } 159 | case MMDrawerSectionShadowToggle:{ 160 | [cell.textLabel setText:@"Show Shadow"]; 161 | if(self.mm_drawerController.showsShadow) 162 | [cell setAccessoryType:UITableViewCellAccessoryCheckmark]; 163 | else 164 | [cell setAccessoryType:UITableViewCellAccessoryNone]; 165 | break; 166 | } 167 | case MMDrawerSectionOpenDrawerGestures:{ 168 | switch (indexPath.row) { 169 | case 0: 170 | [cell.textLabel setText:@"Pan Nav Bar"]; 171 | if((self.mm_drawerController.openDrawerGestureModeMask&MMOpenDrawerGestureModePanningNavigationBar)>0) 172 | [cell setAccessoryType:UITableViewCellAccessoryCheckmark]; 173 | else 174 | [cell setAccessoryType:UITableViewCellAccessoryNone]; 175 | break; 176 | case 1: 177 | [cell.textLabel setText:@"Pan Center View"]; 178 | if((self.mm_drawerController.openDrawerGestureModeMask&MMOpenDrawerGestureModePanningCenterView)>0) 179 | [cell setAccessoryType:UITableViewCellAccessoryCheckmark]; 180 | else 181 | [cell setAccessoryType:UITableViewCellAccessoryNone]; 182 | break; 183 | case 2: 184 | [cell.textLabel setText:@"Bezel Pan Center View"]; 185 | if((self.mm_drawerController.openDrawerGestureModeMask&MMOpenDrawerGestureModeBezelPanningCenterView)>0) 186 | [cell setAccessoryType:UITableViewCellAccessoryCheckmark]; 187 | else 188 | [cell setAccessoryType:UITableViewCellAccessoryNone]; 189 | break; 190 | default: 191 | break; 192 | } 193 | break; 194 | } 195 | case MMDrawerSectionCloseDrawerGestures:{ 196 | switch (indexPath.row) { 197 | case 0: 198 | [cell.textLabel setText:@"Pan Nav Bar"]; 199 | if((self.mm_drawerController.closeDrawerGestureModeMask&MMCloseDrawerGestureModePanningNavigationBar)>0) 200 | [cell setAccessoryType:UITableViewCellAccessoryCheckmark]; 201 | else 202 | [cell setAccessoryType:UITableViewCellAccessoryNone]; 203 | break; 204 | case 1: 205 | [cell.textLabel setText:@"Pan Center View"]; 206 | if((self.mm_drawerController.closeDrawerGestureModeMask&MMCloseDrawerGestureModePanningCenterView)>0) 207 | [cell setAccessoryType:UITableViewCellAccessoryCheckmark]; 208 | else 209 | [cell setAccessoryType:UITableViewCellAccessoryNone]; 210 | break; 211 | case 2: 212 | [cell.textLabel setText:@"Bezel Pan Center View"]; 213 | if((self.mm_drawerController.closeDrawerGestureModeMask&MMCloseDrawerGestureModeBezelPanningCenterView)>0) 214 | [cell setAccessoryType:UITableViewCellAccessoryCheckmark]; 215 | else 216 | [cell setAccessoryType:UITableViewCellAccessoryNone]; 217 | break; 218 | case 3: 219 | [cell.textLabel setText:@"Tap Nav Bar"]; 220 | if((self.mm_drawerController.closeDrawerGestureModeMask&MMCloseDrawerGestureModeTapNavigationBar)>0) 221 | [cell setAccessoryType:UITableViewCellAccessoryCheckmark]; 222 | else 223 | [cell setAccessoryType:UITableViewCellAccessoryNone]; 224 | break; 225 | case 4: 226 | [cell.textLabel setText:@"Tap Center View"]; 227 | if((self.mm_drawerController.closeDrawerGestureModeMask&MMCloseDrawerGestureModeTapCenterView)>0) 228 | [cell setAccessoryType:UITableViewCellAccessoryCheckmark]; 229 | else 230 | [cell setAccessoryType:UITableViewCellAccessoryNone]; 231 | break; 232 | case 5: 233 | [cell.textLabel setText:@"Pan Drawer View"]; 234 | if((self.mm_drawerController.closeDrawerGestureModeMask&MMCloseDrawerGestureModePanningDrawerView)>0) 235 | [cell setAccessoryType:UITableViewCellAccessoryCheckmark]; 236 | else 237 | [cell setAccessoryType:UITableViewCellAccessoryNone]; 238 | break; 239 | default: 240 | break; 241 | } 242 | break; 243 | } 244 | case MMDrawerSectionCenterHiddenInteraction:{ 245 | [cell setSelectionStyle:UITableViewCellSelectionStyleBlue]; 246 | switch (indexPath.row) { 247 | case 0: 248 | [cell.textLabel setText:@"None"]; 249 | if(self.mm_drawerController.centerHiddenInteractionMode == MMDrawerOpenCenterInteractionModeNone) 250 | [cell setAccessoryType:UITableViewCellAccessoryCheckmark]; 251 | else 252 | [cell setAccessoryType:UITableViewCellAccessoryNone]; 253 | break; 254 | case 1: 255 | [cell.textLabel setText:@"Full"]; 256 | if(self.mm_drawerController.centerHiddenInteractionMode == MMDrawerOpenCenterInteractionModeFull) 257 | [cell setAccessoryType:UITableViewCellAccessoryCheckmark]; 258 | else 259 | [cell setAccessoryType:UITableViewCellAccessoryNone]; 260 | break; 261 | case 2: 262 | [cell.textLabel setText:@"Nav Bar Only"]; 263 | if(self.mm_drawerController.centerHiddenInteractionMode == MMDrawerOpenCenterInteractionModeNavigationBarOnly) 264 | [cell setAccessoryType:UITableViewCellAccessoryCheckmark]; 265 | else 266 | [cell setAccessoryType:UITableViewCellAccessoryNone]; 267 | break; 268 | 269 | default: 270 | break; 271 | } 272 | break; 273 | } 274 | case MMDrawerSectionStretchDrawer:{ 275 | [cell.textLabel setText:@"Stretch Drawer"]; 276 | if(self.mm_drawerController.shouldStretchDrawer) 277 | [cell setAccessoryType:UITableViewCellAccessoryCheckmark]; 278 | else 279 | [cell setAccessoryType:UITableViewCellAccessoryNone]; 280 | break; 281 | } 282 | default: 283 | break; 284 | } 285 | 286 | return cell; 287 | } 288 | 289 | -(NSString*)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section{ 290 | switch (section) { 291 | case MMDrawerSectionViewSelection: 292 | return @"New Center View"; 293 | case MMDrawerSectionDrawerWidth: 294 | return @"Drawer Width"; 295 | case MMDrawerSectionShadowToggle: 296 | return @"Shadow"; 297 | case MMDrawerSectionOpenDrawerGestures: 298 | return @"Drawer Open Gestures"; 299 | case MMDrawerSectionCloseDrawerGestures: 300 | return @"Drawer Close Gestures"; 301 | case MMDrawerSectionCenterHiddenInteraction: 302 | return @"Open Center Interaction Mode"; 303 | case MMDrawerSectionStretchDrawer: 304 | return @"Strech Drawer"; 305 | default: 306 | return nil; 307 | } 308 | } 309 | 310 | -(UIView*)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{ 311 | MMSideDrawerSectionHeaderView * headerView; 312 | headerView = [[MMSideDrawerSectionHeaderView alloc] initWithFrame:CGRectMake(0, 0, CGRectGetWidth(tableView.bounds), 56.0)]; 313 | [headerView setAutoresizingMask:UIViewAutoresizingFlexibleHeight|UIViewAutoresizingFlexibleWidth]; 314 | [headerView setTitle:[tableView.dataSource tableView:tableView titleForHeaderInSection:section]]; 315 | return headerView; 316 | } 317 | 318 | -(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{ 319 | return 56.0; 320 | } 321 | 322 | -(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{ 323 | return 40.0; 324 | } 325 | 326 | -(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{ 327 | return 0.0; 328 | } 329 | 330 | #pragma mark - Table view delegate 331 | 332 | - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath 333 | { 334 | switch (indexPath.section) { 335 | case MMDrawerSectionViewSelection:{ 336 | MMExampleCenterTableViewController * center = [[MMExampleCenterTableViewController alloc] init]; 337 | 338 | UINavigationController * nav = [[MMNavigationController alloc] initWithRootViewController:center]; 339 | 340 | if(indexPath.row%2==0){ 341 | [self.mm_drawerController 342 | setCenterViewController:nav 343 | withCloseAnimation:YES 344 | completion:nil]; 345 | } 346 | else { 347 | [self.mm_drawerController 348 | setCenterViewController:nav 349 | withFullCloseAnimation:YES 350 | completion:nil]; 351 | } 352 | break; 353 | } 354 | 355 | case MMDrawerSectionDrawerWidth:{ 356 | //Implement in Subclass 357 | break; 358 | } 359 | case MMDrawerSectionShadowToggle:{ 360 | [self.mm_drawerController setShowsShadow:!self.mm_drawerController.showsShadow]; 361 | [tableView reloadSections:[NSIndexSet indexSetWithIndex:indexPath.section] withRowAnimation:UITableViewRowAnimationNone]; 362 | break; 363 | } 364 | case MMDrawerSectionOpenDrawerGestures:{ 365 | switch (indexPath.row) { 366 | case 0: 367 | self.mm_drawerController.openDrawerGestureModeMask ^= MMOpenDrawerGestureModePanningNavigationBar; 368 | break; 369 | case 1: 370 | self.mm_drawerController.openDrawerGestureModeMask ^= MMOpenDrawerGestureModePanningCenterView; 371 | break; 372 | case 2: 373 | self.mm_drawerController.openDrawerGestureModeMask ^= MMOpenDrawerGestureModeBezelPanningCenterView; 374 | break; 375 | default: 376 | break; 377 | } 378 | [tableView reloadRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationNone]; 379 | break; 380 | } 381 | case MMDrawerSectionCloseDrawerGestures:{ 382 | switch (indexPath.row) { 383 | case 0: 384 | self.mm_drawerController.closeDrawerGestureModeMask ^= MMCloseDrawerGestureModePanningNavigationBar; 385 | break; 386 | case 1: 387 | self.mm_drawerController.closeDrawerGestureModeMask ^= MMCloseDrawerGestureModePanningCenterView; 388 | break; 389 | case 2: 390 | self.mm_drawerController.closeDrawerGestureModeMask ^= MMCloseDrawerGestureModeBezelPanningCenterView; 391 | break; 392 | case 3: 393 | self.mm_drawerController.closeDrawerGestureModeMask ^= MMCloseDrawerGestureModeTapNavigationBar; 394 | break; 395 | case 4: 396 | self.mm_drawerController.closeDrawerGestureModeMask ^= MMCloseDrawerGestureModeTapCenterView; 397 | break; 398 | case 5: 399 | self.mm_drawerController.closeDrawerGestureModeMask ^= MMCloseDrawerGestureModePanningDrawerView; 400 | break; 401 | default: 402 | break; 403 | } 404 | [tableView reloadRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationNone]; 405 | break; 406 | } 407 | case MMDrawerSectionCenterHiddenInteraction:{ 408 | self.mm_drawerController.centerHiddenInteractionMode = indexPath.row; 409 | [tableView reloadSections:[NSIndexSet indexSetWithIndex:indexPath.section] withRowAnimation:UITableViewRowAnimationNone]; 410 | break; 411 | } 412 | case MMDrawerSectionStretchDrawer:{ 413 | self.mm_drawerController.shouldStretchDrawer = !self.mm_drawerController.shouldStretchDrawer; 414 | [tableView reloadRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationNone]; 415 | break; 416 | } 417 | default: 418 | break; 419 | } 420 | [tableView selectRowAtIndexPath:indexPath animated:NO scrollPosition:UITableViewScrollPositionNone]; 421 | [tableView deselectRowAtIndexPath:indexPath animated:YES]; 422 | } 423 | 424 | @end 425 | -------------------------------------------------------------------------------- /KitchenSink/ExampleFiles/MMExampleViewController.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2013 Mutual Mobile (http://mutualmobile.com/) 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a copy 4 | // of this software and associated documentation files (the "Software"), to deal 5 | // in the Software without restriction, including without limitation the rights 6 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | // copies of the Software, and to permit persons to whom the Software is 8 | // furnished to do so, subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included in 11 | // all copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | // THE SOFTWARE. 20 | 21 | #import 22 | 23 | @interface MMExampleViewController : UIViewController 24 | 25 | -(void)contentSizeDidChange:(NSString*)size; 26 | 27 | @end 28 | -------------------------------------------------------------------------------- /KitchenSink/ExampleFiles/MMExampleViewController.m: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2013 Mutual Mobile (http://mutualmobile.com/) 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a copy 4 | // of this software and associated documentation files (the "Software"), to deal 5 | // in the Software without restriction, including without limitation the rights 6 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | // copies of the Software, and to permit persons to whom the Software is 8 | // furnished to do so, subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included in 11 | // all copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | // THE SOFTWARE. 20 | 21 | #import "MMExampleViewController.h" 22 | 23 | @interface MMExampleViewController () 24 | 25 | @end 26 | 27 | @implementation MMExampleViewController 28 | 29 | - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil 30 | { 31 | self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; 32 | if (self) { 33 | // Custom initialization 34 | } 35 | return self; 36 | } 37 | 38 | - (void)viewDidLoad 39 | { 40 | [super viewDidLoad]; 41 | //contentSizeDidChangeNotification 通知: 用户更改了系统默认字体,比如 放大模式 会发送这个通知 42 | [[NSNotificationCenter defaultCenter] 43 | addObserver:self 44 | selector:@selector(contentSizeDidChangeNotification:) 45 | name:UIContentSizeCategoryDidChangeNotification 46 | object:nil]; 47 | } 48 | 49 | - (void)dealloc{ 50 | [[NSNotificationCenter defaultCenter] 51 | removeObserver:self]; 52 | } 53 | 54 | /// 父类接收通知 子类去实现方法, 适合所有控制器都要实现某个通知的例子 55 | /// 这个方法 设为public 56 | -(void)contentSizeDidChangeNotification:(NSNotification*)notification{ 57 | /// UIContentSizeCategoryNewValueKey 58 | /// 用户更改了系统默认字体大小 具体字体大小值 59 | [self contentSizeDidChange:notification.userInfo[UIContentSizeCategoryNewValueKey]]; 60 | } 61 | 62 | -(void)contentSizeDidChange:(NSString *)size{ 63 | //Implement in subclass 64 | } 65 | 66 | @end 67 | -------------------------------------------------------------------------------- /KitchenSink/ExampleFiles/MMLogoView.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2013 Mutual Mobile (http://mutualmobile.com/) 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a copy 4 | // of this software and associated documentation files (the "Software"), to deal 5 | // in the Software without restriction, including without limitation the rights 6 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | // copies of the Software, and to permit persons to whom the Software is 8 | // furnished to do so, subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included in 11 | // all copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | // THE SOFTWARE. 20 | 21 | 22 | #import 23 | 24 | @interface MMLogoView : UIView 25 | 26 | @end 27 | -------------------------------------------------------------------------------- /KitchenSink/ExampleFiles/MMLogoView.m: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2013 Mutual Mobile (http://mutualmobile.com/) 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a copy 4 | // of this software and associated documentation files (the "Software"), to deal 5 | // in the Software without restriction, including without limitation the rights 6 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | // copies of the Software, and to permit persons to whom the Software is 8 | // furnished to do so, subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included in 11 | // all copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | // THE SOFTWARE. 20 | 21 | 22 | #import "MMLogoView.h" 23 | 24 | @implementation MMLogoView 25 | 26 | -(id)initWithFrame:(CGRect)frame{ 27 | self = [super initWithFrame:frame]; 28 | if(self) { 29 | [self setBackgroundColor:[UIColor clearColor]]; 30 | } 31 | return self; 32 | } 33 | 34 | -(void)drawRect:(CGRect)rect{ 35 | //// General Declarations 36 | CGContextRef context = UIGraphicsGetCurrentContext(); 37 | 38 | //// Color Declarations 39 | UIColor* mmFill = [UIColor colorWithRed: 0 green: 0 blue: 0 alpha: 0.196]; 40 | UIColor* shape1DropShadowColor = [UIColor colorWithRed: 1 green: 1 blue: 1 alpha: 0.4]; 41 | UIColor* shape1InnerShadowColor = [UIColor colorWithRed: 0 green: 0 blue: 0 alpha: 0.392]; 42 | 43 | //// Shadow Declarations 44 | UIColor* mmDropShadow = shape1DropShadowColor; 45 | CGSize mmDropShadowOffset = CGSizeMake(0.1, 1.1); 46 | CGFloat mmDropShadowBlurRadius = 0; 47 | UIColor* mmInnerShadow = shape1InnerShadowColor; 48 | CGSize mmInnerShadowOffset = CGSizeMake(0.1, 1.1); 49 | CGFloat mmInnerShadowBlurRadius = 0; 50 | 51 | //// Frames 52 | CGRect frame = self.bounds; 53 | 54 | 55 | //// mmGroup 56 | { 57 | //// mmShape Drawing 58 | UIBezierPath* mmShapePath = [UIBezierPath bezierPath]; 59 | [mmShapePath moveToPoint: CGPointMake(CGRectGetMinX(frame) + 0.51759 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.96761 * CGRectGetHeight(frame))]; 60 | [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))]; 61 | [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))]; 62 | [mmShapePath addLineToPoint: CGPointMake(CGRectGetMinX(frame) + 0.31904 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.75325 * CGRectGetHeight(frame))]; 63 | [mmShapePath addLineToPoint: CGPointMake(CGRectGetMinX(frame) + 0.30262 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.75459 * CGRectGetHeight(frame))]; 64 | [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))]; 65 | [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))]; 66 | [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))]; 67 | [mmShapePath addLineToPoint: CGPointMake(CGRectGetMinX(frame) + 0.45528 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.15799 * CGRectGetHeight(frame))]; 68 | [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))]; 69 | [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))]; 70 | [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))]; 71 | [mmShapePath addLineToPoint: CGPointMake(CGRectGetMinX(frame) + 0.19390 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.48951 * CGRectGetHeight(frame))]; 72 | [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))]; 73 | [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))]; 74 | [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))]; 75 | [mmShapePath addLineToPoint: CGPointMake(CGRectGetMinX(frame) + 0.68812 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.37025 * CGRectGetHeight(frame))]; 76 | [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))]; 77 | [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))]; 78 | [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))]; 79 | [mmShapePath addLineToPoint: CGPointMake(CGRectGetMinX(frame) + 0.42673 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.70173 * CGRectGetHeight(frame))]; 80 | [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))]; 81 | [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))]; 82 | [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))]; 83 | [mmShapePath addLineToPoint: CGPointMake(CGRectGetMinX(frame) + 0.92092 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.58246 * CGRectGetHeight(frame))]; 84 | [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))]; 85 | [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))]; 86 | [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))]; 87 | [mmShapePath addLineToPoint: CGPointMake(CGRectGetMinX(frame) + 0.65956 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.91398 * CGRectGetHeight(frame))]; 88 | [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))]; 89 | [mmShapePath addLineToPoint: CGPointMake(CGRectGetMinX(frame) + 0.51759 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.96761 * CGRectGetHeight(frame))]; 90 | [mmShapePath closePath]; 91 | [mmShapePath moveToPoint: CGPointMake(CGRectGetMinX(frame) + 0.51965 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.81940 * CGRectGetHeight(frame))]; 92 | [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))]; 93 | [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))]; 94 | [mmShapePath addLineToPoint: CGPointMake(CGRectGetMinX(frame) + 0.80659 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.47824 * CGRectGetHeight(frame))]; 95 | [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))]; 96 | [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))]; 97 | [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))]; 98 | [mmShapePath addLineToPoint: CGPointMake(CGRectGetMinX(frame) + 0.31239 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.59752 * CGRectGetHeight(frame))]; 99 | [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))]; 100 | [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))]; 101 | [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))]; 102 | [mmShapePath addLineToPoint: CGPointMake(CGRectGetMinX(frame) + 0.57377 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.26601 * CGRectGetHeight(frame))]; 103 | [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))]; 104 | [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))]; 105 | [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))]; 106 | [mmShapePath addLineToPoint: CGPointMake(CGRectGetMinX(frame) + 0.07956 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.38530 * CGRectGetHeight(frame))]; 107 | [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))]; 108 | [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))]; 109 | [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))]; 110 | [mmShapePath addLineToPoint: CGPointMake(CGRectGetMinX(frame) + 0.34095 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.05378 * CGRectGetHeight(frame))]; 111 | [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))]; 112 | [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))]; 113 | [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))]; 114 | [mmShapePath addLineToPoint: CGPointMake(CGRectGetMinX(frame) + 0.68143 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.21454 * CGRectGetHeight(frame))]; 115 | [mmShapePath addLineToPoint: CGPointMake(CGRectGetMinX(frame) + 0.69786 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.21318 * CGRectGetHeight(frame))]; 116 | [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))]; 117 | [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))]; 118 | [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))]; 119 | [mmShapePath addLineToPoint: CGPointMake(CGRectGetMinX(frame) + 0.54521 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.80977 * CGRectGetHeight(frame))]; 120 | [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))]; 121 | [mmShapePath addLineToPoint: CGPointMake(CGRectGetMinX(frame) + 0.51965 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.81940 * CGRectGetHeight(frame))]; 122 | [mmShapePath closePath]; 123 | CGContextSaveGState(context); 124 | CGContextSetShadowWithColor(context, mmDropShadowOffset, mmDropShadowBlurRadius, mmDropShadow.CGColor); 125 | 126 | CGContextSetBlendMode(context, kCGBlendModeOverlay); 127 | [mmFill setFill]; 128 | [mmShapePath fill]; 129 | 130 | ////// mmShape Inner Shadow 131 | CGRect mmShapeBorderRect = CGRectInset([mmShapePath bounds], -mmInnerShadowBlurRadius, -mmInnerShadowBlurRadius); 132 | mmShapeBorderRect = CGRectOffset(mmShapeBorderRect, -mmInnerShadowOffset.width, -mmInnerShadowOffset.height); 133 | mmShapeBorderRect = CGRectInset(CGRectUnion(mmShapeBorderRect, [mmShapePath bounds]), -1, -1); 134 | 135 | UIBezierPath* mmShapeNegativePath = [UIBezierPath bezierPathWithRect: mmShapeBorderRect]; 136 | [mmShapeNegativePath appendPath: mmShapePath]; 137 | mmShapeNegativePath.usesEvenOddFillRule = YES; 138 | 139 | CGContextSaveGState(context); 140 | { 141 | CGFloat xOffset = mmInnerShadowOffset.width + round(mmShapeBorderRect.size.width); 142 | CGFloat yOffset = mmInnerShadowOffset.height; 143 | CGContextSetShadowWithColor(context, 144 | CGSizeMake(xOffset + copysign(0.1, xOffset), yOffset + copysign(0.1, yOffset)), 145 | mmInnerShadowBlurRadius, 146 | mmInnerShadow.CGColor); 147 | 148 | [mmShapePath addClip]; 149 | CGAffineTransform transform = CGAffineTransformMakeTranslation(-round(mmShapeBorderRect.size.width), 0); 150 | [mmShapeNegativePath applyTransform: transform]; 151 | [[UIColor grayColor] setFill]; 152 | [mmShapeNegativePath fill]; 153 | } 154 | CGContextRestoreGState(context); 155 | 156 | CGContextRestoreGState(context); 157 | } 158 | } 159 | 160 | @end 161 | -------------------------------------------------------------------------------- /KitchenSink/ExampleFiles/MMNavigationController.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2013 Mutual Mobile (http://mutualmobile.com/) 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a copy 4 | // of this software and associated documentation files (the "Software"), to deal 5 | // in the Software without restriction, including without limitation the rights 6 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | // copies of the Software, and to permit persons to whom the Software is 8 | // furnished to do so, subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included in 11 | // all copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | // THE SOFTWARE. 20 | 21 | #import 22 | 23 | @interface MMNavigationController : UINavigationController 24 | 25 | @end 26 | -------------------------------------------------------------------------------- /KitchenSink/ExampleFiles/MMNavigationController.m: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2013 Mutual Mobile (http://mutualmobile.com/) 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a copy 4 | // of this software and associated documentation files (the "Software"), to deal 5 | // in the Software without restriction, including without limitation the rights 6 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | // copies of the Software, and to permit persons to whom the Software is 8 | // furnished to do so, subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included in 11 | // all copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | // THE SOFTWARE. 20 | #import "MMNavigationController.h" 21 | #import "UIViewController+MMDrawerController.h" 22 | 23 | @interface MMNavigationController () 24 | 25 | @end 26 | 27 | @implementation MMNavigationController 28 | 29 | -(UIStatusBarStyle)preferredStatusBarStyle{ 30 | if(self.mm_drawerController.showsStatusBarBackgroundView){ 31 | return UIStatusBarStyleLightContent; 32 | } 33 | else { 34 | return UIStatusBarStyleDefault; 35 | } 36 | } 37 | 38 | @end 39 | -------------------------------------------------------------------------------- /KitchenSink/ExampleFiles/MMSideDrawerSectionHeaderView.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2013 Mutual Mobile (http://mutualmobile.com/) 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a copy 4 | // of this software and associated documentation files (the "Software"), to deal 5 | // in the Software without restriction, including without limitation the rights 6 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | // copies of the Software, and to permit persons to whom the Software is 8 | // furnished to do so, subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included in 11 | // all copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | // THE SOFTWARE. 20 | 21 | 22 | #import 23 | 24 | @interface MMSideDrawerSectionHeaderView : UIView 25 | 26 | @property (nonatomic, copy) NSString * title; 27 | 28 | @end 29 | -------------------------------------------------------------------------------- /KitchenSink/ExampleFiles/MMSideDrawerSectionHeaderView.m: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2013 Mutual Mobile (http://mutualmobile.com/) 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a copy 4 | // of this software and associated documentation files (the "Software"), to deal 5 | // in the Software without restriction, including without limitation the rights 6 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | // copies of the Software, and to permit persons to whom the Software is 8 | // furnished to do so, subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included in 11 | // all copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | // THE SOFTWARE. 20 | 21 | #import "MMSideDrawerSectionHeaderView.h" 22 | #import 23 | 24 | @interface MMSideDrawerSectionHeaderView () 25 | @property (nonatomic, strong) UILabel * label; 26 | @end 27 | 28 | @implementation MMSideDrawerSectionHeaderView 29 | 30 | - (id)initWithFrame:(CGRect)frame 31 | { 32 | self = [super initWithFrame:frame]; 33 | if (self) { 34 | // Initialization code 35 | 36 | [self setBackgroundColor:[UIColor colorWithRed:110./255.0 37 | green:113.0/255.0 38 | blue:115.0/255.0 39 | alpha:1.0]]; 40 | 41 | _label = [[UILabel alloc] initWithFrame:CGRectMake(15, CGRectGetMaxY(self.bounds)-28,CGRectGetWidth(self.bounds)-30, 22)]; 42 | 43 | 44 | if([[UIFont class] respondsToSelector:@selector(preferredFontForTextStyle:)]){ 45 | [self.label setFont:[UIFont preferredFontForTextStyle:UIFontTextStyleCaption1]]; 46 | } 47 | else { 48 | [self.label setFont:[UIFont boldSystemFontOfSize:12.0]]; 49 | } 50 | 51 | [self.label setBackgroundColor:[UIColor clearColor]]; 52 | [self.label setTextColor:[UIColor colorWithRed:203.0/255.0 53 | green:206.0/255.0 54 | blue:209.0/255.0 55 | alpha:1.0]]; 56 | [self.label setAutoresizingMask:UIViewAutoresizingFlexibleWidth|UIViewAutoresizingFlexibleTopMargin]; 57 | [self addSubview:self.label]; 58 | [self setClipsToBounds:NO]; 59 | } 60 | return self; 61 | } 62 | 63 | -(void)setTitle:(NSString *)title{ 64 | _title = title; 65 | [self.label setText:[self.title uppercaseString]]; 66 | } 67 | 68 | -(void)drawRect:(CGRect)rect{ 69 | //// General Declarations 70 | CGContextRef context = UIGraphicsGetCurrentContext(); 71 | UIColor * lineColor = [UIColor colorWithRed:94.0/255.0 72 | green:97.0/255.0 73 | blue:99.0/255.0 74 | alpha:1.0]; 75 | CGContextSetStrokeColorWithColor(context, lineColor.CGColor); 76 | 77 | CGContextSetLineWidth(context, 1.0); 78 | 79 | CGContextMoveToPoint(context, CGRectGetMinX(self.bounds), CGRectGetMaxY(self.bounds)-.5); //start at this point 80 | 81 | CGContextAddLineToPoint(context, CGRectGetMaxX(self.bounds), CGRectGetMaxY(self.bounds)-.5); //draw to this point 82 | 83 | CGContextStrokePath(context); 84 | } 85 | 86 | @end 87 | -------------------------------------------------------------------------------- /KitchenSink/ExampleFiles/MMSideDrawerTableViewCell.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2013 Mutual Mobile (http://mutualmobile.com/) 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a copy 4 | // of this software and associated documentation files (the "Software"), to deal 5 | // in the Software without restriction, including without limitation the rights 6 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | // copies of the Software, and to permit persons to whom the Software is 8 | // furnished to do so, subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included in 11 | // all copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | // THE SOFTWARE. 20 | 21 | 22 | #import "MMTableViewCell.h" 23 | 24 | @interface MMSideDrawerTableViewCell : MMTableViewCell 25 | 26 | @end 27 | -------------------------------------------------------------------------------- /KitchenSink/ExampleFiles/MMSideDrawerTableViewCell.m: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2013 Mutual Mobile (http://mutualmobile.com/) 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a copy 4 | // of this software and associated documentation files (the "Software"), to deal 5 | // in the Software without restriction, including without limitation the rights 6 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | // copies of the Software, and to permit persons to whom the Software is 8 | // furnished to do so, subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included in 11 | // all copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | // THE SOFTWARE. 20 | 21 | 22 | #import "MMSideDrawerTableViewCell.h" 23 | 24 | @implementation MMSideDrawerTableViewCell 25 | 26 | - (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier 27 | { 28 | self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]; 29 | if (self) { 30 | [self setAccessoryCheckmarkColor:[UIColor whiteColor]]; 31 | 32 | UIView * backgroundView = [[UIView alloc] initWithFrame:self.bounds]; 33 | [backgroundView setAutoresizingMask:UIViewAutoresizingFlexibleHeight|UIViewAutoresizingFlexibleWidth]; 34 | UIColor * backgroundColor; 35 | backgroundColor = [UIColor colorWithRed:122.0/255.0 36 | green:126.0/255.0 37 | blue:128.0/255.0 38 | alpha:1.0]; 39 | [backgroundView setBackgroundColor:backgroundColor]; 40 | 41 | [self setBackgroundView:backgroundView]; 42 | 43 | [self.textLabel setBackgroundColor:[UIColor clearColor]]; 44 | [self.textLabel setTextColor:[UIColor 45 | colorWithRed:230.0/255.0 46 | green:236.0/255.0 47 | blue:242.0/255.0 48 | alpha:1.0]]; 49 | } 50 | return self; 51 | } 52 | 53 | -(void)updateContentForNewContentSize{ 54 | if([[UIFont class] respondsToSelector:@selector(preferredFontForTextStyle:)]){ 55 | [self.textLabel setFont:[UIFont preferredFontForTextStyle:UIFontTextStyleBody]]; 56 | } 57 | else { 58 | [self.textLabel setFont:[UIFont boldSystemFontOfSize:16.0]]; 59 | } 60 | } 61 | 62 | @end 63 | -------------------------------------------------------------------------------- /KitchenSink/ExampleFiles/MMTableViewCell.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2013 Mutual Mobile (http://mutualmobile.com/) 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a copy 4 | // of this software and associated documentation files (the "Software"), to deal 5 | // in the Software without restriction, including without limitation the rights 6 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | // copies of the Software, and to permit persons to whom the Software is 8 | // furnished to do so, subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included in 11 | // all copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | // THE SOFTWARE. 20 | 21 | 22 | #import 23 | 24 | @interface MMTableViewCell : UITableViewCell 25 | 26 | @property (nonatomic, strong) UIColor * accessoryCheckmarkColor; 27 | @property (nonatomic, strong) UIColor * disclosureIndicatorColor; 28 | 29 | -(void)updateContentForNewContentSize; 30 | 31 | @end 32 | -------------------------------------------------------------------------------- /KitchenSink/ExampleFiles/MMTableViewCell.m: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2013 Mutual Mobile (http://mutualmobile.com/) 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a copy 4 | // of this software and associated documentation files (the "Software"), to deal 5 | // in the Software without restriction, including without limitation the rights 6 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | // copies of the Software, and to permit persons to whom the Software is 8 | // furnished to do so, subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included in 11 | // all copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | // THE SOFTWARE. 20 | 21 | 22 | #import "MMTableViewCell.h" 23 | 24 | @interface MMDisclosureIndicator : UIView 25 | @property (nonatomic, strong) UIColor * color; 26 | @end 27 | 28 | @implementation MMDisclosureIndicator 29 | -(id)initWithFrame:(CGRect)frame{ 30 | self = [super initWithFrame:frame]; 31 | if(self){ 32 | [self setBackgroundColor:[UIColor clearColor]]; 33 | [self setColor:[UIColor whiteColor]]; 34 | } 35 | return self; 36 | } 37 | 38 | -(void)drawRect:(CGRect)rect{ 39 | //// General Declarations 40 | CGContextRef context = UIGraphicsGetCurrentContext(); 41 | 42 | //// Color Declarations 43 | UIColor* shadow; 44 | shadow = [UIColor clearColor]; 45 | UIColor* chevronColor = self.color; 46 | 47 | //// Shadow Declarations 48 | CGSize shadowOffset = CGSizeMake(0.1, 1.1); 49 | CGFloat shadowBlurRadius = 0; 50 | 51 | //// Frames 52 | CGRect frame = self.bounds; 53 | 54 | 55 | //// chevron Drawing 56 | UIBezierPath* chevronPath = [UIBezierPath bezierPath]; 57 | [chevronPath moveToPoint: CGPointMake(CGRectGetMinX(frame) + 0.22000 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.01667 * CGRectGetHeight(frame))]; 58 | [chevronPath addLineToPoint: CGPointMake(CGRectGetMinX(frame) + 0.98000 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.48333 * CGRectGetHeight(frame))]; 59 | [chevronPath addLineToPoint: CGPointMake(CGRectGetMinX(frame) + 0.22000 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.98333 * CGRectGetHeight(frame))]; 60 | [chevronPath addLineToPoint: CGPointMake(CGRectGetMinX(frame) + 0.02000 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.81667 * CGRectGetHeight(frame))]; 61 | [chevronPath addLineToPoint: CGPointMake(CGRectGetMinX(frame) + 0.54000 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.48333 * CGRectGetHeight(frame))]; 62 | [chevronPath addLineToPoint: CGPointMake(CGRectGetMinX(frame) + 0.02000 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.15000 * CGRectGetHeight(frame))]; 63 | [chevronPath addLineToPoint: CGPointMake(CGRectGetMinX(frame) + 0.22000 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.01667 * CGRectGetHeight(frame))]; 64 | [chevronPath closePath]; 65 | CGContextSaveGState(context); 66 | CGContextSetShadowWithColor(context, shadowOffset, shadowBlurRadius, shadow.CGColor); 67 | [chevronColor setFill]; 68 | [chevronPath fill]; 69 | CGContextRestoreGState(context); 70 | } 71 | @end 72 | 73 | @interface MMCustomCheckmark : UIControl 74 | @property (nonatomic, strong) UIColor * color; 75 | @end 76 | 77 | @implementation MMCustomCheckmark 78 | 79 | -(id)initWithFrame:(CGRect)frame{ 80 | self = [super initWithFrame:frame]; 81 | if(self) { 82 | [self setBackgroundColor:[UIColor clearColor]]; 83 | [self setUserInteractionEnabled:NO]; 84 | } 85 | return self; 86 | } 87 | 88 | -(void)drawRect:(CGRect)rect{ 89 | //// Color Declarations 90 | UIColor* checkMarkColor = self.color; 91 | 92 | //// Frames 93 | CGRect frame = self.bounds; 94 | 95 | 96 | //// checkMark Drawing 97 | UIBezierPath* checkMarkPath = [UIBezierPath bezierPath]; 98 | [checkMarkPath moveToPoint: CGPointMake(CGRectGetMinX(frame) + 0.07087 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.48855 * CGRectGetHeight(frame))]; 99 | [checkMarkPath addLineToPoint: CGPointMake(CGRectGetMinX(frame) + 0.12500 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.45284 * CGRectGetHeight(frame))]; 100 | [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))]; 101 | [checkMarkPath addLineToPoint: CGPointMake(CGRectGetMinX(frame) + 0.51450 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.79528 * CGRectGetHeight(frame))]; 102 | [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))]; 103 | [checkMarkPath addLineToPoint: CGPointMake(CGRectGetMinX(frame) + 0.38337 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.96429 * CGRectGetHeight(frame))]; 104 | [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))]; 105 | [checkMarkPath addLineToPoint: CGPointMake(CGRectGetMinX(frame) + 0.04800 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.58613 * CGRectGetHeight(frame))]; 106 | [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))]; 107 | [checkMarkPath closePath]; 108 | [checkMarkPath moveToPoint: CGPointMake(CGRectGetMinX(frame) + 0.92048 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.00641 * CGRectGetHeight(frame))]; 109 | [checkMarkPath addLineToPoint: CGPointMake(CGRectGetMinX(frame) + 0.93750 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.02427 * CGRectGetHeight(frame))]; 110 | [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))]; 111 | [checkMarkPath addLineToPoint: CGPointMake(CGRectGetMinX(frame) + 0.51450 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.93814 * CGRectGetHeight(frame))]; 112 | [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))]; 113 | [checkMarkPath addLineToPoint: CGPointMake(CGRectGetMinX(frame) + 0.32087 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.89286 * CGRectGetHeight(frame))]; 114 | [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))]; 115 | [checkMarkPath addLineToPoint: CGPointMake(CGRectGetMinX(frame) + 0.83511 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.03255 * CGRectGetHeight(frame))]; 116 | [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))]; 117 | [checkMarkPath closePath]; 118 | [checkMarkPath moveToPoint: CGPointMake(CGRectGetMinX(frame) + 0.37500 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.78572 * CGRectGetHeight(frame))]; 119 | [checkMarkPath addLineToPoint: CGPointMake(CGRectGetMinX(frame) + 0.43750 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.78572 * CGRectGetHeight(frame))]; 120 | [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))]; 121 | [checkMarkPath addLineToPoint: CGPointMake(CGRectGetMinX(frame) + 0.50000 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.92857 * CGRectGetHeight(frame))]; 122 | [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))]; 123 | [checkMarkPath addLineToPoint: CGPointMake(CGRectGetMinX(frame) + 0.37500 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 1.00000 * CGRectGetHeight(frame))]; 124 | [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))]; 125 | [checkMarkPath addLineToPoint: CGPointMake(CGRectGetMinX(frame) + 0.31250 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.85714 * CGRectGetHeight(frame))]; 126 | [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))]; 127 | [checkMarkPath closePath]; 128 | [checkMarkColor setFill]; 129 | [checkMarkPath fill]; 130 | } 131 | 132 | -(void)setSelected:(BOOL)selected{ 133 | [super setSelected:selected]; 134 | [self setNeedsDisplay]; 135 | } 136 | 137 | @end 138 | 139 | @implementation MMTableViewCell 140 | 141 | - (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier 142 | { 143 | self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]; 144 | if (self) { 145 | [self setAccessoryCheckmarkColor:[UIColor whiteColor]]; 146 | [self setDisclosureIndicatorColor:[UIColor whiteColor]]; 147 | [self updateContentForNewContentSize]; 148 | } 149 | return self; 150 | } 151 | 152 | - (void)setSelected:(BOOL)selected animated:(BOOL)animated 153 | { 154 | [super setSelected:selected animated:animated]; 155 | 156 | // Configure the view for the selected state 157 | } 158 | 159 | - (void)setAccessoryType:(UITableViewCellAccessoryType)accessoryType{ 160 | [super setAccessoryType:accessoryType]; 161 | if(accessoryType == UITableViewCellAccessoryCheckmark){ 162 | MMCustomCheckmark * customCheckmark = [[MMCustomCheckmark alloc] initWithFrame:CGRectMake(0, 0, 15, 15)]; 163 | [customCheckmark setColor:self.accessoryCheckmarkColor]; 164 | [self setAccessoryView:customCheckmark]; 165 | } 166 | else if(accessoryType == UITableViewCellAccessoryDisclosureIndicator){ 167 | MMDisclosureIndicator * di = [[MMDisclosureIndicator alloc] initWithFrame:CGRectMake(0, 0, 10, 14)]; 168 | [di setColor:self.disclosureIndicatorColor]; 169 | [self setAccessoryView:di]; 170 | } 171 | else { 172 | [self setAccessoryView:nil]; 173 | } 174 | } 175 | 176 | -(void)prepareForReuse{ 177 | [super prepareForReuse]; 178 | [self updateContentForNewContentSize]; 179 | } 180 | 181 | -(void)updateContentForNewContentSize{ 182 | 183 | } 184 | 185 | @end 186 | -------------------------------------------------------------------------------- /KitchenSink/ExampleFiles/en.lproj/InfoPlist.strings: -------------------------------------------------------------------------------- 1 | /* Localized versions of Info.plist keys */ 2 | 3 | -------------------------------------------------------------------------------- /KitchenSink/ExampleFiles/main.m: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2013 Mutual Mobile (http://mutualmobile.com/) 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a copy 4 | // of this software and associated documentation files (the "Software"), to deal 5 | // in the Software without restriction, including without limitation the rights 6 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | // copies of the Software, and to permit persons to whom the Software is 8 | // furnished to do so, subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included in 11 | // all copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | // THE SOFTWARE. 20 | 21 | 22 | #import 23 | 24 | #import "MMAppDelegate.h" 25 | 26 | int main(int argc, char *argv[]) 27 | { 28 | @autoreleasepool { 29 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([MMAppDelegate class])); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /KitchenSink/Icons/Icon-72.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Flyfishering/MMDrawerController/abd8b1bbd2a48803950ec8f8c363e15549262d9d/KitchenSink/Icons/Icon-72.png -------------------------------------------------------------------------------- /KitchenSink/Icons/Icon-72@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Flyfishering/MMDrawerController/abd8b1bbd2a48803950ec8f8c363e15549262d9d/KitchenSink/Icons/Icon-72@2x.png -------------------------------------------------------------------------------- /KitchenSink/Icons/Icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Flyfishering/MMDrawerController/abd8b1bbd2a48803950ec8f8c363e15549262d9d/KitchenSink/Icons/Icon.png -------------------------------------------------------------------------------- /KitchenSink/Icons/Icon@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Flyfishering/MMDrawerController/abd8b1bbd2a48803950ec8f8c363e15549262d9d/KitchenSink/Icons/Icon@2x.png -------------------------------------------------------------------------------- /KitchenSink/MMDrawerControllerKitchenSink.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /KitchenSink/MMDrawerControllerKitchenSink.xcodeproj/project.xcworkspace/xcshareddata/MMDrawerControllerKitchenSink.xccheckout: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDESourceControlProjectFavoriteDictionaryKey 6 | 7 | IDESourceControlProjectIdentifier 8 | 88813EDE-C4BC-4EAD-BA3F-F5FC71109468 9 | IDESourceControlProjectName 10 | MMDrawerControllerKitchenSink 11 | IDESourceControlProjectOriginsDictionary 12 | 13 | BF2FE30DD30E807A424B26D63A15FEB4A29593EB 14 | https://github.com/mutualmobile/MMDrawerController.git 15 | 16 | IDESourceControlProjectPath 17 | KitchenSink/MMDrawerControllerKitchenSink.xcodeproj 18 | IDESourceControlProjectRelativeInstallPathDictionary 19 | 20 | BF2FE30DD30E807A424B26D63A15FEB4A29593EB 21 | ../../.. 22 | 23 | IDESourceControlProjectURL 24 | https://github.com/mutualmobile/MMDrawerController.git 25 | IDESourceControlProjectVersion 26 | 111 27 | IDESourceControlProjectWCCIdentifier 28 | BF2FE30DD30E807A424B26D63A15FEB4A29593EB 29 | IDESourceControlProjectWCConfigurations 30 | 31 | 32 | IDESourceControlRepositoryExtensionIdentifierKey 33 | public.vcs.git 34 | IDESourceControlWCCIdentifierKey 35 | BF2FE30DD30E807A424B26D63A15FEB4A29593EB 36 | IDESourceControlWCCName 37 | MMDrawerController-GitHub 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /KitchenSink/MMDrawerControllerKitchenSink.xcodeproj/xcshareddata/xcschemes/MMDrawerControllerKitchenSink.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 39 | 40 | 41 | 42 | 51 | 52 | 58 | 59 | 60 | 61 | 62 | 63 | 69 | 70 | 76 | 77 | 78 | 79 | 81 | 82 | 85 | 86 | 87 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2013 Mutual Mobile (http://mutualmobile.com/) 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in 11 | all copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | THE SOFTWARE. 20 | -------------------------------------------------------------------------------- /MMDrawerController.podspec: -------------------------------------------------------------------------------- 1 | Pod::Spec.new do |s| 2 | s.name = "MMDrawerController" 3 | s.version = "0.6.0" 4 | s.summary = "A lightweight, easy-to-use side drawer navigation controller." 5 | s.homepage = "https://github.com/mutualmobile/MMDrawerController" 6 | s.license = { :type => 'MIT', :file => 'LICENSE' } 7 | s.author = { "Kevin Harwood" => "kevin.harwood@mutualmobile.com" } 8 | s.source = { :git => "https://github.com/mutualmobile/MMDrawerController.git", :tag => "0.6.0" } 9 | s.platform = :ios, '7.0' 10 | s.requires_arc = true 11 | s.screenshots = [ "http://mutualmobile.github.io/MMDrawerController/ExampleImages/example1.png", 12 | "http://mutualmobile.github.io/MMDrawerController/ExampleImages/example2.png" ] 13 | 14 | s.subspec 'Core' do |ss| 15 | ss.source_files = 'MMDrawerController/MMDrawerController.{h,m}', 'MMDrawerController/UIViewController+MMDrawerController*' 16 | ss.framework = 'QuartzCore' 17 | end 18 | 19 | s.subspec 'MMDrawerBarButtonItem' do |ss| 20 | ss.source_files = 'MMDrawerController/MMDrawerBarButtonItem.{h,m}' 21 | ss.dependency 'MMDrawerController/Core' 22 | end 23 | 24 | s.subspec 'MMDrawerVisualStates' do |ss| 25 | ss.source_files = 'MMDrawerController/MMDrawerVisualState.{h,m}' 26 | ss.dependency 'MMDrawerController/Core' 27 | end 28 | 29 | s.subspec 'Subclass' do |ss| 30 | ss.source_files = 'MMDrawerController/MMDrawerController+Subclass.h' 31 | ss.dependency 'MMDrawerController/Core' 32 | end 33 | end 34 | -------------------------------------------------------------------------------- /MMDrawerController/MMDrawerBarButtonItem.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2013 Mutual Mobile (http://mutualmobile.com/) 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a copy 4 | // of this software and associated documentation files (the "Software"), to deal 5 | // in the Software without restriction, including without limitation the rights 6 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | // copies of the Software, and to permit persons to whom the Software is 8 | // furnished to do so, subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included in 11 | // all copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | // THE SOFTWARE. 20 | 21 | #import 22 | 23 | /** 24 | `MMDrawerBarButtonItem` provides convenience methods to create `UIBarButtonItems` with a default hamburger-menu asset. 25 | 26 | 提供了 方便的方法 去 创建 一个 汉堡菜单 导航栏按钮 27 | */ 28 | 29 | @interface MMDrawerBarButtonItem : UIBarButtonItem 30 | 31 | ///--------------------------------------- 32 | /// @name Initializing a `MMDrawerBarButtonItem` 33 | ///--------------------------------------- 34 | 35 | /** 36 | Creates and initializes an `MMDrawerBarButtonItem` without a border. 37 | 38 | @param target The target to forward the `action` to when the button is pressed. 39 | @param action The action to call when the button is pressed. 40 | 41 | @return The newly-initialized bar button item. 42 | 43 | 创建 MMDrawerBarButtonItem 44 | */ 45 | -(instancetype)initWithTarget:(id)target action:(SEL)action; 46 | 47 | /** 48 | Returns the current color of the menu button for the state requested. This property is deprecated in iOS 7.0. Use `tintColor` instead. 49 | 50 | @param state The UIControl state that the color is being requested for. 51 | 52 | @return The menu button color for the requested state. 53 | */ 54 | -(UIColor *)menuButtonColorForState:(UIControlState)state __attribute__((deprecated("Use tintColor instead"))); 55 | 56 | /** 57 | 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. 58 | 59 | @param color The color to set. 60 | @param state The state to set the color for. 61 | */ 62 | -(void)setMenuButtonColor:(UIColor *)color forState:(UIControlState)state __attribute__((deprecated("Use tintColor instead"))); 63 | 64 | /** 65 | 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. 66 | 67 | @param state The UIControl state that the color is being requested for. 68 | 69 | @return The menu button color for the requested state. 70 | */ 71 | -(UIColor *)shadowColorForState:(UIControlState)state __attribute__((deprecated("Shadow is no longer supported"))); 72 | 73 | /** 74 | 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. 75 | 76 | @param color The color to set. 77 | @param state The state to set the color for. 78 | */ 79 | -(void)setShadowColor:(UIColor *)color forState:(UIControlState)state __attribute__((deprecated("Shadow is no longer supported"))); 80 | 81 | @end 82 | -------------------------------------------------------------------------------- /MMDrawerController/MMDrawerBarButtonItem.m: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2013 Mutual Mobile (http://mutualmobile.com/) 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a copy 4 | // of this software and associated documentation files (the "Software"), to deal 5 | // in the Software without restriction, including without limitation the rights 6 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | // copies of the Software, and to permit persons to whom the Software is 8 | // furnished to do so, subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included in 11 | // all copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | // THE SOFTWARE. 20 | 21 | 22 | #import "MMDrawerBarButtonItem.h" 23 | 24 | @interface MMDrawerMenuButtonView : UIButton 25 | @property (nonatomic,strong) UIColor * menuButtonNormalColor; 26 | @property (nonatomic,strong) UIColor * menuButtonHighlightedColor; 27 | 28 | @property (nonatomic,strong) UIColor * shadowNormalColor; 29 | @property (nonatomic,strong) UIColor * shadowHighlightedColor; 30 | 31 | -(UIColor *)menuButtonColorForState:(UIControlState)state; 32 | -(void)setMenuButtonColor:(UIColor *)color forState:(UIControlState)state; 33 | 34 | -(UIColor *)shadowColorForState:(UIControlState)state; 35 | -(void)setShadowColor:(UIColor *)color forState:(UIControlState)state; 36 | 37 | @end 38 | 39 | @implementation MMDrawerMenuButtonView 40 | 41 | -(instancetype)initWithFrame:(CGRect)frame{ 42 | self = [super initWithFrame:frame]; 43 | if(self){ 44 | [self setMenuButtonNormalColor:[[UIColor whiteColor] colorWithAlphaComponent:0.9f]]; 45 | [self setMenuButtonHighlightedColor:[UIColor colorWithRed:139.0/255.0 46 | green:135.0/255.0 47 | blue:136.0/255.0 48 | alpha:0.9f]]; 49 | 50 | [self setShadowNormalColor:[[UIColor blackColor] colorWithAlphaComponent:0.5f]]; 51 | [self setShadowHighlightedColor:[[UIColor blackColor] colorWithAlphaComponent:0.2f]]; 52 | } 53 | return self; 54 | } 55 | 56 | -(UIColor *)menuButtonColorForState:(UIControlState)state{ 57 | UIColor * color; 58 | switch (state) { 59 | case UIControlStateNormal: 60 | color = self.menuButtonNormalColor; 61 | break; 62 | case UIControlStateHighlighted: 63 | color = self.menuButtonHighlightedColor; 64 | break; 65 | default: 66 | break; 67 | } 68 | return color; 69 | } 70 | 71 | -(void)setMenuButtonColor:(UIColor *)color forState:(UIControlState)state{ 72 | switch (state) { 73 | case UIControlStateNormal: 74 | [self setMenuButtonNormalColor:color]; 75 | break; 76 | case UIControlStateHighlighted: 77 | [self setMenuButtonHighlightedColor:color]; 78 | break; 79 | default: 80 | break; 81 | } 82 | [self setNeedsDisplay]; 83 | } 84 | 85 | -(UIColor *)shadowColorForState:(UIControlState)state{ 86 | UIColor * color; 87 | switch (state) { 88 | case UIControlStateNormal: 89 | color = self.shadowNormalColor; 90 | break; 91 | case UIControlStateHighlighted: 92 | color = self.shadowHighlightedColor; 93 | break; 94 | default: 95 | break; 96 | } 97 | return color; 98 | } 99 | 100 | -(void)setShadowColor:(UIColor *)color forState:(UIControlState)state{ 101 | switch (state) { 102 | case UIControlStateNormal: 103 | [self setShadowNormalColor:color]; 104 | break; 105 | case UIControlStateHighlighted: 106 | [self setShadowHighlightedColor:color]; 107 | break; 108 | default: 109 | break; 110 | } 111 | [self setNeedsDisplay]; 112 | } 113 | 114 | -(void)drawRect:(CGRect)rect{ 115 | //// General Declarations 116 | CGContextRef context = UIGraphicsGetCurrentContext(); 117 | 118 | //Sizes 119 | CGFloat buttonWidth = CGRectGetWidth(self.bounds)*.80; 120 | CGFloat buttonHeight = CGRectGetHeight(self.bounds)*.16; 121 | CGFloat xOffset = CGRectGetWidth(self.bounds)*.10; 122 | CGFloat yOffset = CGRectGetHeight(self.bounds)*.12; 123 | CGFloat cornerRadius = 1.0; 124 | 125 | //// Color Declarations 126 | UIColor* buttonColor = [self menuButtonColorForState:self.state]; 127 | UIColor* shadowColor = [self shadowColorForState:self.state]; 128 | 129 | 130 | //// Shadow Declarations 131 | UIColor* shadow = shadowColor; 132 | CGSize shadowOffset = CGSizeMake(0.0, 1.0); 133 | CGFloat shadowBlurRadius = 0; 134 | 135 | //// Top Bun Drawing 136 | UIBezierPath* topBunPath = [UIBezierPath bezierPathWithRoundedRect:CGRectMake(xOffset, yOffset, buttonWidth, buttonHeight) cornerRadius:cornerRadius]; 137 | CGContextSaveGState(context); 138 | CGContextSetShadowWithColor(context, shadowOffset, shadowBlurRadius, shadow.CGColor); 139 | [buttonColor setFill]; 140 | [topBunPath fill]; 141 | CGContextRestoreGState(context); 142 | 143 | //// Meat Drawing 144 | UIBezierPath* meatPath = [UIBezierPath bezierPathWithRoundedRect:CGRectMake(xOffset, yOffset*2 + buttonHeight, buttonWidth, buttonHeight) cornerRadius:cornerRadius]; 145 | CGContextSaveGState(context); 146 | CGContextSetShadowWithColor(context, shadowOffset, shadowBlurRadius, shadow.CGColor); 147 | [buttonColor setFill]; 148 | [meatPath fill]; 149 | CGContextRestoreGState(context); 150 | 151 | //// Bottom Bun Drawing 152 | UIBezierPath* bottomBunPath = [UIBezierPath bezierPathWithRoundedRect:CGRectMake(xOffset, yOffset*3 + buttonHeight*2, buttonWidth, buttonHeight) cornerRadius:cornerRadius]; 153 | CGContextSaveGState(context); 154 | CGContextSetShadowWithColor(context, shadowOffset, shadowBlurRadius, shadow.CGColor); 155 | [buttonColor setFill]; 156 | [bottomBunPath fill]; 157 | CGContextRestoreGState(context); 158 | } 159 | 160 | -(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{ 161 | [super touchesBegan:touches withEvent:event]; 162 | [self setNeedsDisplay]; 163 | } 164 | 165 | -(void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event{ 166 | [super touchesEnded:touches withEvent:event]; 167 | [self setNeedsDisplay]; 168 | } 169 | 170 | -(void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event{ 171 | [super touchesCancelled:touches withEvent:event]; 172 | [self setNeedsDisplay]; 173 | } 174 | 175 | -(void)setSelected:(BOOL)selected{ 176 | [super setSelected:selected]; 177 | [self setNeedsDisplay]; 178 | } 179 | 180 | -(void)setHighlighted:(BOOL)highlighted{ 181 | [super setHighlighted:highlighted]; 182 | [self setNeedsDisplay]; 183 | } 184 | 185 | -(void)setTintColor:(UIColor *)tintColor{ 186 | if([super respondsToSelector:@selector(setTintColor:)]){ 187 | [super setTintColor:tintColor]; 188 | } 189 | } 190 | 191 | -(void)tintColorDidChange{ 192 | [self setNeedsDisplay]; 193 | } 194 | 195 | @end 196 | 197 | @interface MMDrawerBarButtonItem () 198 | @property (nonatomic,strong) MMDrawerMenuButtonView * buttonView; 199 | 200 | @end 201 | 202 | @implementation MMDrawerBarButtonItem 203 | 204 | +(UIImage*)drawerButtonItemImage{ 205 | 206 | static UIImage *drawerButtonImage = nil; 207 | static dispatch_once_t onceToken; 208 | dispatch_once(&onceToken, ^{ 209 | 210 | UIGraphicsBeginImageContextWithOptions( CGSizeMake(26, 26), NO, 0 ); 211 | 212 | //// Color Declarations 213 | UIColor* fillColor = [UIColor whiteColor]; 214 | 215 | //// Frames 216 | CGRect frame = CGRectMake(0, 0, 26, 26); 217 | 218 | //// Bottom Bar Drawing 219 | 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)]; 220 | [fillColor setFill]; 221 | [bottomBarPath fill]; 222 | 223 | 224 | //// Middle Bar Drawing 225 | 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)]; 226 | [fillColor setFill]; 227 | [middleBarPath fill]; 228 | 229 | 230 | //// Top Bar Drawing 231 | 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)]; 232 | [fillColor setFill]; 233 | [topBarPath fill]; 234 | 235 | drawerButtonImage = UIGraphicsGetImageFromCurrentImageContext(); 236 | }); 237 | 238 | return drawerButtonImage; 239 | } 240 | 241 | -(instancetype)initWithTarget:(id)target action:(SEL)action{ 242 | 243 | if((floor(NSFoundationVersionNumber) > NSFoundationVersionNumber_iOS_6_1)){ 244 | return [self initWithImage:[self.class drawerButtonItemImage] 245 | style:UIBarButtonItemStylePlain 246 | target:target 247 | action:action]; 248 | } 249 | else { 250 | MMDrawerMenuButtonView * buttonView = [[MMDrawerMenuButtonView alloc] initWithFrame:CGRectMake(0, 0, 26, 26)]; 251 | [buttonView addTarget:self action:@selector(touchUpInside:) forControlEvents:UIControlEventTouchUpInside]; 252 | self = [self initWithCustomView:buttonView]; 253 | if(self){ 254 | [self setButtonView:buttonView]; 255 | } 256 | self.action = action; 257 | self.target = target; 258 | return self; 259 | } 260 | } 261 | 262 | -(instancetype)initWithCoder:(NSCoder *)aDecoder{ 263 | // non-ideal way to get the target/action, but it works 264 | UIBarButtonItem* barButtonItem = [[UIBarButtonItem alloc] initWithCoder: aDecoder]; 265 | return [self initWithTarget:barButtonItem.target action:barButtonItem.action]; 266 | } 267 | 268 | -(void)touchUpInside:(id)sender{ 269 | 270 | #pragma clang diagnostic push 271 | #pragma clang diagnostic ignored "-Warc-performSelector-leaks" 272 | [self.target performSelector:self.action withObject:sender]; 273 | #pragma clang diagnostic pop; 274 | 275 | } 276 | 277 | -(UIColor *)menuButtonColorForState:(UIControlState)state{ 278 | return [self.buttonView menuButtonColorForState:state]; 279 | } 280 | 281 | -(void)setMenuButtonColor:(UIColor *)color forState:(UIControlState)state{ 282 | [self.buttonView setMenuButtonColor:color forState:state]; 283 | } 284 | 285 | -(UIColor *)shadowColorForState:(UIControlState)state{ 286 | return [self.buttonView shadowColorForState:state]; 287 | } 288 | 289 | -(void)setShadowColor:(UIColor *)color forState:(UIControlState)state{ 290 | [self.buttonView setShadowColor:color forState:state]; 291 | } 292 | 293 | -(void)setTintColor:(UIColor *)tintColor{ 294 | if([super respondsToSelector:@selector(setTintColor:)]){ 295 | [super setTintColor:tintColor]; 296 | } 297 | if([self.buttonView respondsToSelector:@selector(setTintColor:)]){ 298 | [self.buttonView setTintColor:tintColor]; 299 | } 300 | } 301 | 302 | @end 303 | -------------------------------------------------------------------------------- /MMDrawerController/MMDrawerController+Subclass.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2013 Mutual Mobile (http://mutualmobile.com/) 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a copy 4 | // of this software and associated documentation files (the "Software"), to deal 5 | // in the Software without restriction, including without limitation the rights 6 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | // copies of the Software, and to permit persons to whom the Software is 8 | // furnished to do so, subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included in 11 | // all copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | // THE SOFTWARE. 20 | 21 | #import "MMDrawerController.h" 22 | 23 | /** 24 | 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`. 25 | 26 | None of these methods are meant to be called by non-subclasses of `MMDrawerController`. 27 | */ 28 | 29 | @interface MMDrawerController (Subclass) 30 | ///--------------------------------------- 31 | /// @name Gesture Interaction 32 | ///--------------------------------------- 33 | /** 34 | `MMDrawerController`'s single-tap gesture recognizer callback. This method is called every time the `UITapGestureRecognizer` is triggered. 35 | 36 | @param tapGesture The single-tap gesture recognizer instance that triggered the callback 37 | */ 38 | -(void)tapGestureCallback:(UITapGestureRecognizer *)tapGesture __attribute((objc_requires_super)); 39 | 40 | /** 41 | `MMDrawerController`'s pan gesture recognizer callback. This method is called every time the `UIPanGestureRecognizer` is updated. 42 | 43 | @warning This method do the minimal amount of work to keep the pan gesture responsive. 44 | 45 | @param panGesture The pan gesture recognizer instance that triggered the callback 46 | */ 47 | -(void)panGestureCallback:(UIPanGestureRecognizer *)panGesture __attribute((objc_requires_super)); 48 | 49 | /** 50 | A `UIGestureRecognizerDelegate` method that is queried by `MMDrawerController`'s gestures to determine if it should receive the touch. 51 | 52 | @param gestureRecognizer The gesture recognizer that is asking if it should recieve a touch 53 | @param touch The touch in question in gestureRecognizer.view's coordinate space 54 | */ 55 | -(BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch __attribute((objc_requires_super)); 56 | 57 | ///--------------------------------------- 58 | /// @name Drawer Presentation 59 | ///--------------------------------------- 60 | /** 61 | 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. 62 | 63 | @param drawer The drawer side that will be presented 64 | @param animated A boolean that indicates whether the presentation is being animated or not 65 | */ 66 | -(void)prepareToPresentDrawer:(MMDrawerSide)drawer animated:(BOOL)animated __attribute((objc_requires_super)); 67 | 68 | ///--------------------------------------- 69 | /// @name Opening/Closing Drawer 70 | ///--------------------------------------- 71 | /** 72 | 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. 73 | 74 | @param animated A boolean that indicates whether the drawer should close with animation 75 | @param velocity A float indicating how fast the drawer should close 76 | @param animationOptions A mask defining the animation options of the animation 77 | @param completion A completion block to be called when the drawer is finished closing 78 | */ 79 | -(void)closeDrawerAnimated:(BOOL)animated velocity:(CGFloat)velocity animationOptions:(UIViewAnimationOptions)options completion:(void (^)(BOOL))completion __attribute((objc_requires_super)); 80 | 81 | /** 82 | 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. 83 | 84 | @param drawerSide The drawer side that will be opened 85 | @param animated A boolean that indicates whether the drawer should open with animation 86 | @param velocity A float indicating how fast the drawer should open 87 | @param animationOptions A mask defining the animation options of the animation 88 | @param completion A completion block to be called when the drawer is finished opening 89 | */ 90 | -(void)openDrawerSide:(MMDrawerSide)drawerSide animated:(BOOL)animated velocity:(CGFloat)velocity animationOptions:(UIViewAnimationOptions)options completion:(void (^)(BOOL))completion __attribute((objc_requires_super)); 91 | 92 | ///--------------------------------------- 93 | /// @name `UIViewController` Subclass Methods 94 | ///--------------------------------------- 95 | /** 96 | Included here to ensure subclasses call `super`. 97 | 98 | @param toInterfaceOrientation The interface orientation that the interface is moving to 99 | @param duration The duration of the interface orientation animation 100 | */ 101 | -(void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration __attribute((objc_requires_super)); 102 | 103 | /** 104 | Included here to ensure subclasses call `super`. 105 | 106 | @param toInterfaceOrientation The interface orientation that the interface is moving to 107 | @param duration The duration of the interface orientation animation 108 | */ 109 | -(void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration __attribute((objc_requires_super)); 110 | 111 | @end 112 | -------------------------------------------------------------------------------- /MMDrawerController/MMDrawerVisualState.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2013 Mutual Mobile (http://mutualmobile.com/) 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a copy 4 | // of this software and associated documentation files (the "Software"), to deal 5 | // in the Software without restriction, including without limitation the rights 6 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | // copies of the Software, and to permit persons to whom the Software is 8 | // furnished to do so, subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included in 11 | // all copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | // THE SOFTWARE. 20 | 21 | 22 | #import 23 | #import "MMDrawerController.h" 24 | 25 | /** 26 | `MMDrawerVisualState` provides prebuilt visual state update blocks that can be used in the callback block of `MMDrawerController` for drawer animation. 27 | */ 28 | 29 | @interface MMDrawerVisualState : NSObject 30 | 31 | /** 32 | 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. 33 | 34 | @return The visual state block. 35 | */ 36 | +(MMDrawerControllerDrawerVisualStateBlock)slideAndScaleVisualStateBlock; 37 | 38 | /** 39 | 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. 40 | 41 | @return The visual state block. 42 | */ 43 | +(MMDrawerControllerDrawerVisualStateBlock)slideVisualStateBlock; 44 | 45 | /** 46 | Creates a swinging door visual state block that gives the user an experience that animates the drawer in along the hinge. 47 | 48 | @return The visual state block. 49 | */ 50 | +(MMDrawerControllerDrawerVisualStateBlock)swingingDoorVisualStateBlock; 51 | 52 | /** 53 | 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. 54 | 55 | @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. 56 | 57 | @return The visual state block. 58 | */ 59 | +(MMDrawerControllerDrawerVisualStateBlock)parallaxVisualStateBlockWithParallaxFactor:(CGFloat)parallaxFactor; 60 | 61 | @end 62 | -------------------------------------------------------------------------------- /MMDrawerController/MMDrawerVisualState.m: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2013 Mutual Mobile (http://mutualmobile.com/) 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a copy 4 | // of this software and associated documentation files (the "Software"), to deal 5 | // in the Software without restriction, including without limitation the rights 6 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | // copies of the Software, and to permit persons to whom the Software is 8 | // furnished to do so, subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included in 11 | // all copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | // THE SOFTWARE. 20 | 21 | 22 | #import "MMDrawerVisualState.h" 23 | #import 24 | 25 | @implementation MMDrawerVisualState 26 | +(MMDrawerControllerDrawerVisualStateBlock)slideAndScaleVisualStateBlock{ 27 | MMDrawerControllerDrawerVisualStateBlock visualStateBlock = 28 | ^(MMDrawerController * drawerController, MMDrawerSide drawerSide, CGFloat percentVisible){ 29 | CGFloat minScale = .90; 30 | CGFloat scale = minScale + (percentVisible*(1.0-minScale)); 31 | CATransform3D scaleTransform = CATransform3DMakeScale(scale, scale, scale); 32 | 33 | CGFloat maxDistance = 50; 34 | CGFloat distance = maxDistance * percentVisible; 35 | CATransform3D translateTransform = CATransform3DIdentity; 36 | UIViewController * sideDrawerViewController; 37 | if(drawerSide == MMDrawerSideLeft) { 38 | sideDrawerViewController = drawerController.leftDrawerViewController; 39 | translateTransform = CATransform3DMakeTranslation((maxDistance-distance), 0.0, 0.0); 40 | } 41 | else if(drawerSide == MMDrawerSideRight){ 42 | sideDrawerViewController = drawerController.rightDrawerViewController; 43 | translateTransform = CATransform3DMakeTranslation(-(maxDistance-distance), 0.0, 0.0); 44 | } 45 | 46 | [sideDrawerViewController.view.layer setTransform:CATransform3DConcat(scaleTransform, translateTransform)]; 47 | [sideDrawerViewController.view setAlpha:percentVisible]; 48 | }; 49 | return visualStateBlock; 50 | } 51 | 52 | +(MMDrawerControllerDrawerVisualStateBlock)slideVisualStateBlock{ 53 | return [self parallaxVisualStateBlockWithParallaxFactor:1.0]; 54 | } 55 | 56 | 57 | +(MMDrawerControllerDrawerVisualStateBlock)swingingDoorVisualStateBlock{ 58 | MMDrawerControllerDrawerVisualStateBlock visualStateBlock = 59 | ^(MMDrawerController * drawerController, MMDrawerSide drawerSide, CGFloat percentVisible){ 60 | UIViewController * sideDrawerViewController; 61 | CGPoint anchorPoint; 62 | CGFloat maxDrawerWidth = 0.0; 63 | CGFloat xOffset; 64 | CGFloat angle = 0.0; 65 | 66 | if(drawerSide==MMDrawerSideLeft){ 67 | 68 | sideDrawerViewController = drawerController.leftDrawerViewController; 69 | anchorPoint = CGPointMake(1.0, .5); 70 | maxDrawerWidth = MAX(drawerController.maximumLeftDrawerWidth,drawerController.visibleLeftDrawerWidth); 71 | xOffset = -(maxDrawerWidth/2.0) + (maxDrawerWidth)*percentVisible; 72 | angle = -M_PI_2+(percentVisible*M_PI_2); 73 | } 74 | else { 75 | sideDrawerViewController = drawerController.rightDrawerViewController; 76 | anchorPoint = CGPointMake(0.0, .5); 77 | maxDrawerWidth = MAX(drawerController.maximumRightDrawerWidth,drawerController.visibleRightDrawerWidth); 78 | xOffset = (maxDrawerWidth/2.0) - (maxDrawerWidth)*percentVisible; 79 | angle = M_PI_2-(percentVisible*M_PI_2); 80 | } 81 | 82 | [sideDrawerViewController.view.layer setAnchorPoint:anchorPoint]; 83 | [sideDrawerViewController.view.layer setShouldRasterize:YES]; 84 | [sideDrawerViewController.view.layer setRasterizationScale:[[UIScreen mainScreen] scale]]; 85 | 86 | CATransform3D swingingDoorTransform = CATransform3DIdentity; 87 | if (percentVisible <= 1.f) { 88 | 89 | CATransform3D identity = CATransform3DIdentity; 90 | identity.m34 = -1.0/1000.0; 91 | CATransform3D rotateTransform = CATransform3DRotate(identity, angle, 0.0, 1.0, 0.0); 92 | 93 | CATransform3D translateTransform = CATransform3DMakeTranslation(xOffset, 0.0, 0.0); 94 | 95 | CATransform3D concatTransform = CATransform3DConcat(rotateTransform, translateTransform); 96 | 97 | swingingDoorTransform = concatTransform; 98 | } 99 | else{ 100 | CATransform3D overshootTransform = CATransform3DMakeScale(percentVisible, 1.f, 1.f); 101 | 102 | NSInteger scalingModifier = 1.f; 103 | if (drawerSide == MMDrawerSideRight) { 104 | scalingModifier = -1.f; 105 | } 106 | 107 | overshootTransform = CATransform3DTranslate(overshootTransform, scalingModifier*maxDrawerWidth/2, 0.f, 0.f); 108 | swingingDoorTransform = overshootTransform; 109 | } 110 | 111 | [sideDrawerViewController.view.layer setTransform:swingingDoorTransform]; 112 | }; 113 | return visualStateBlock; 114 | } 115 | 116 | +(MMDrawerControllerDrawerVisualStateBlock)parallaxVisualStateBlockWithParallaxFactor:(CGFloat)parallaxFactor{ 117 | MMDrawerControllerDrawerVisualStateBlock visualStateBlock = 118 | ^(MMDrawerController * drawerController, MMDrawerSide drawerSide, CGFloat percentVisible){ 119 | NSParameterAssert(parallaxFactor >= 1.0); 120 | CATransform3D transform = CATransform3DIdentity; 121 | UIViewController * sideDrawerViewController; 122 | if(drawerSide == MMDrawerSideLeft) { 123 | sideDrawerViewController = drawerController.leftDrawerViewController; 124 | //取最大值 125 | CGFloat distance = MAX(drawerController.maximumLeftDrawerWidth,drawerController.visibleLeftDrawerWidth); 126 | if (percentVisible <= 1.f) { 127 | //3D 转化 128 | transform = CATransform3DMakeTranslation((-distance)/parallaxFactor+(distance*percentVisible/parallaxFactor), 0.0, 0.0); 129 | } 130 | else{ 131 | transform = CATransform3DMakeScale(percentVisible, 1.f, 1.f); 132 | transform = CATransform3DTranslate(transform, drawerController.maximumLeftDrawerWidth*(percentVisible-1.f)/2, 0.f, 0.f); 133 | } 134 | } 135 | else if(drawerSide == MMDrawerSideRight){ 136 | sideDrawerViewController = drawerController.rightDrawerViewController; 137 | CGFloat distance = MAX(drawerController.maximumRightDrawerWidth,drawerController.visibleRightDrawerWidth); 138 | if(percentVisible <= 1.f){ 139 | transform = CATransform3DMakeTranslation((distance)/parallaxFactor-(distance*percentVisible)/parallaxFactor, 0.0, 0.0); 140 | } 141 | else{ 142 | transform = CATransform3DMakeScale(percentVisible, 1.f, 1.f); 143 | transform = CATransform3DTranslate(transform, -drawerController.maximumRightDrawerWidth*(percentVisible-1.f)/2, 0.f, 0.f); 144 | } 145 | } 146 | 147 | //两边 控制器 视图 变化 148 | [sideDrawerViewController.view.layer setTransform:transform]; 149 | }; 150 | return visualStateBlock; 151 | } 152 | 153 | @end 154 | -------------------------------------------------------------------------------- /MMDrawerController/UIViewController+MMDrawerController.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2013 Mutual Mobile (http://mutualmobile.com/) 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a copy 4 | // of this software and associated documentation files (the "Software"), to deal 5 | // in the Software without restriction, including without limitation the rights 6 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | // copies of the Software, and to permit persons to whom the Software is 8 | // furnished to do so, subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included in 11 | // all copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | // THE SOFTWARE. 20 | 21 | #import 22 | 23 | #import "MMDrawerController.h" 24 | 25 | /** 26 | 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. 27 | */ 28 | 29 | @interface UIViewController (MMDrawerController) 30 | 31 | ///--------------------------------------- 32 | /// @name Accessing Drawer View Controller Properties 33 | ///--------------------------------------- 34 | 35 | /** 36 | 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. 37 | 如果当前控制器 被MMDrawerController 包含, 则拥有一个 mm_drawerController 属性 38 | 如果 当前控制器 没有 被MMDrawerController 包含, 则 mm_drawerController 属性为 nil 39 | */ 40 | @property(nonatomic, strong, readonly) MMDrawerController *mm_drawerController; 41 | 42 | /** 43 | 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` 44 | */ 45 | @property(nonatomic, assign, readonly) CGRect mm_visibleDrawerFrame; 46 | 47 | @end 48 | -------------------------------------------------------------------------------- /MMDrawerController/UIViewController+MMDrawerController.m: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2013 Mutual Mobile (http://mutualmobile.com/) 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a copy 4 | // of this software and associated documentation files (the "Software"), to deal 5 | // in the Software without restriction, including without limitation the rights 6 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | // copies of the Software, and to permit persons to whom the Software is 8 | // furnished to do so, subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included in 11 | // all copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | // THE SOFTWARE. 20 | 21 | 22 | #import "UIViewController+MMDrawerController.h" 23 | 24 | @implementation UIViewController (MMDrawerController) 25 | 26 | 27 | -(MMDrawerController*)mm_drawerController{ 28 | UIViewController *parentViewController = self.parentViewController; 29 | while (parentViewController != nil) { 30 | if([parentViewController isKindOfClass:[MMDrawerController class]]){ 31 | return (MMDrawerController *)parentViewController; 32 | } 33 | parentViewController = parentViewController.parentViewController; 34 | } 35 | return nil; 36 | } 37 | 38 | -(CGRect)mm_visibleDrawerFrame{ 39 | if([self isEqual:self.mm_drawerController.leftDrawerViewController] || 40 | [self.navigationController isEqual:self.mm_drawerController.leftDrawerViewController]){ 41 | CGRect rect = self.mm_drawerController.view.bounds; 42 | rect.size.width = self.mm_drawerController.maximumLeftDrawerWidth; 43 | if (self.mm_drawerController.showsStatusBarBackgroundView) { 44 | rect.size.height -= 20.0f; 45 | } 46 | return rect; 47 | 48 | } 49 | else if([self isEqual:self.mm_drawerController.rightDrawerViewController] || 50 | [self.navigationController isEqual:self.mm_drawerController.rightDrawerViewController]){ 51 | CGRect rect = self.mm_drawerController.view.bounds; 52 | rect.size.width = self.mm_drawerController.maximumRightDrawerWidth; 53 | rect.origin.x = CGRectGetWidth(self.mm_drawerController.view.bounds)-rect.size.width; 54 | if (self.mm_drawerController.showsStatusBarBackgroundView) { 55 | rect.size.height -= 20.0f; 56 | } 57 | return rect; 58 | } 59 | else { 60 | return CGRectNull; 61 | } 62 | } 63 | 64 | @end 65 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | #Mutual Mobile Drawer Controller 2 | `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. 3 | 4 | `MMDrawerController` 是一个 侧边抽屉导航控制器, 越来越多的应用被设计要支持侧边抽屉导航, 该框架 仅仅支持轻量级的 侧边 抽屉 导航. 提供了多种抽屉展示方式 5 | 6 |

7 | 8 | 9 |

10 | 11 | --- 12 | ##Documentation 13 | Official appledoc documentation can be found at [CocoaDocs](http://cocoadocs.org/docsets/MMDrawerController/). 14 | 15 | 文档 16 | 正式的 appledoc 文档 可以在 这里找到[CocaDocs](http://cocoadocs.org/docsets/MMDrawerController/). 17 | --- 18 | ##Installing MMDrawerController 19 |
20 | You can install MMDrawerController in your project by using [CocoaPods](https://github.com/cocoapods/cocoapods): 21 | 22 | ## 使用 MMDrawerController 23 | 你可以通过 CocoaPods 把 MMDrawerController 集成到我们的项目中 24 | 25 | ```Ruby 26 | pod 'MMDrawerController', '~> 0.5.7' 27 | ``` 28 | 29 | --- 30 | ##Creating a Drawer Controller 31 | Creating a `MMDrawerController` is as easy as creating a center view controller and the drawer view controllers, and init'ing the drawer. 32 | 33 | 创建 `MMDrawerController` 很容易, 一个 中间 的 viewController  一个 抽屉 就可以了 34 | ```Objective-C 35 | UIViewController * leftDrawer = [[UIViewController alloc] init]; 36 | UIViewController * center = [[UIViewController alloc] init]; 37 | UIViewController * rightDrawer = [[UIViewController alloc] init]; 38 | 39 | MMDrawerController * drawerController = [[MMDrawerController alloc] 40 | initWithCenterViewController:center 41 | leftDrawerViewController:leftDrawer 42 | rightDrawerViewController:rightDrawer]; 43 | ``` 44 | 45 | --- 46 | ##Features 47 | 48 | ###UINavigationController Support 49 | `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). 50 | 51 | ### 支持 UINavigationController 52 | `MMDrawerController` 接受 `UINavigationController`  作为 `centerViewController`, 自动更新手势支持, 除此之外 , 任何被包含在 `UINavigationController` 中的子视图控制器 可以通过分类来获得 它 的抽屉容器 `MMDrawerController` 53 | 54 | ###UIGestureRecognizer Support 55 | `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: 56 | 57 | ###手势支持 58 | `MMDrawerController` 支持打开和关闭抽屉的手势 , 下面是关于手势的说明 59 | 60 | * **MMOpenDrawerGestureMode** 61 | * **MMOpenDrawerGestureModePanningNavigationBar**: The user can open the drawer by panning anywhere on the navigation bar. 62 | * **MMOpenDrawerGestureModePanningCenterView**: The user can open the drawer by panning anywhere on the center view. 63 | * **MMOpenDrawerGestureModeBezelPanningCenterView**: The user can open the drawer by starting a pan anywhere within 20 points of the bezel. 64 | * **MMOpenDrawerGestureModeCustom**: The developer can provide a callback block to determine if the gesture should be recognized. More information below. 65 | 66 | * **MMCloseDrawerGestureMode** 67 | * **MMCloseDrawerGestureModePanningNavigationBar**: The user can close the drawer by panning anywhere on the navigation bar. 68 | * **MMCloseDrawerGestureModePanningCenterView**: The user can close the drawer by panning anywhere on the center view. 69 | * **MMCloseDrawerGestureModeBezelPanningCenterView**: The user can close the drawer by starting a pan anywhere within the bezel of the center view. 70 | * **MMCloseDrawerGestureModeTapNavigationBar**: The user can close the drawer by tapping the navigation bar. 71 | * **MMCloseDrawerGestureModeTapCenterView**: The user can close the drawer by tapping the center view. 72 | * **MMCloseDrawerGestureModePanningDrawerView**: The user can close the drawer by panning anywhere on the drawer view. 73 | * **MMCloseDrawerGestureModeCustom**: The developer can provide a callback block to determine if the gesture should be recognized. More information below. 74 | 75 | 76 | --- 77 | 78 | * **MMOpenDrawerGestureMode** 打开抽屉手势 79 | * **MMOpenDrawerGestureModePanningNavigationBar**: 滑动导航栏 打开抽屉. 80 | * **MMOpenDrawerGestureModePanningCenterView**: 滑动中间视图控制器的 view 打开抽屉. 81 | * **MMOpenDrawerGestureModeBezelPanningCenterView**: 在距离中间控制器视图 左右边框20长度范围内 滑动可以打开抽屉. 82 | * **MMOpenDrawerGestureModeCustom**: 自定义手势打开 抽屉. 83 | 84 | * **MMCloseDrawerGestureMode** 关闭抽屉手势 85 | * **MMCloseDrawerGestureModePanningNavigationBar**: 滑动导航栏 关闭抽屉. 86 | * **MMCloseDrawerGestureModePanningCenterView**: 滑动中间视图控制器的 view 关闭抽屉. 87 | * **MMCloseDrawerGestureModeBezelPanningCenterView**: 在距离中间控制器视图 边框20长度范围内 滑动可以关闭抽屉.. 88 | * **MMCloseDrawerGestureModeTapNavigationBar**: 点击导航栏关闭抽屉. 89 | * **MMCloseDrawerGestureModeTapCenterView**: 点击中间视图关闭抽屉. 90 | * **MMCloseDrawerGestureModePanningDrawerView**: 在任何地方滑动 关闭抽屉. 91 | * **MMCloseDrawerGestureModeCustom**: 自定义关闭抽屉 手势 更多信息 往下看. 92 | 93 | 94 | 95 | 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. 96 | 97 | 你可以自由的结合打开和关闭手势, 要注意的是, 这些手势有可能会跟容器内的控制器有冲突, 使用时 要确保不会造成手势冲突, 比如, 当你的中间视图是 `MKMapView` 时, 不能设置打开手势 `MMOpenDrawerGestureModePanningCenterView` 因为它会截断地图的移动手势. 地图将无法滑动. 98 | 99 | ####Custom Gesture Recognizer Support 100 | 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. 101 | 102 | 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: 103 | 104 | ### 自定义手势支持 105 | 从 0.3.0版本开始支持 , 你可以使用这个闭包回调 `setGestureShouldRecognizeTouchBlock:` 方法 来决定是否识别手势. 这个方法提供了三个参数, 抽屉控制器, 手势 `gesture`, 触摸事件`touch` 你可以通过这些参数判断 手势是否被识别, 只有你设置了 `MMOpenDrawerGestureModeCustom`/`MMCloseDrawerGestureModeCustom` 这个 `block` 才会生效 106 | 107 | 比如: 当你的中间控制器 内 有多个元素, 只有你滑动其中一个子元素时 才能打开抽屉, 你要确保 `openDrawerGestureModeMask` 中包含 `MMOpenDrawerGestureModeCustom` 闭包的实现如下: 108 | 109 | ```Objective-C 110 | [myDrawerController 111 | setGestureShouldRecognizeTouchBlock:^BOOL(MMDrawerController *drawerController, UIGestureRecognizer *gesture, UITouch *touch) { 112 | 113 |     // 是否识别手势   114 |     BOOL shouldRecognizeTouch = NO; 115 |     //判断抽屉有没有打开 是不是滑动手势 116 |     if(drawerController.openSide == MMDrawerSideNone && 117 | [gesture isKindOfClass:[UIPanGestureRecognizer class]]){ 118 | //拿到 特定的元素customView 119 |         UIView * customView = [drawerController.centerViewController myCustomSubview]; 120 | //拿到 手势在customView中的点 121 |         CGPoint location = [touch locationInView:customView]; 122 | //点location是否在customView范围内 123 |         shouldRecognizeTouch = (CGRectContainsPoint(customView.bounds, location)); 124 | } 125 | return shouldRecognizeTouch; 126 | }]; 127 | ``` 128 | 129 | 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. 130 | 131 | 注意: 这时 `openDrawerGestureModeMask` 不能包含 `MMOpenDrawerGestureModePanningCenterView` ,因为 这个手势会自动让中间控制器视图所有的元素通过滑动打开抽屉.(我们的要求是只要其中某一个特定的元素才能滑动打开抽屉) 132 | 133 | 134 | ###Custom Drawer Open/Close Animations 135 | `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. 136 | 137 | For example, to set the alpha of the side drawer controller from 0 to 1 during an animation, you would do the following: 138 | 139 | 140 | ### 自定义 抽屉打开/关闭 动画 141 | `MMDrawerController` 提供了一个闭包回调 当抽屉打开和关闭时候 可以自定义动画效果, 来跟新抽屉的可见状态 142 | 例如: 设置一个抽屉控制器的透明度从 0 到 1 做动画, 可以使用下面的代码 143 | 144 | ```Objective-C 145 | [drawerController 146 | setDrawerVisualStateBlock:^(MMDrawerController *drawerController, MMDrawerSide drawerSide, CGFloat percentVisible) { 147 | UIViewController * sideDrawerViewController; 148 | //坐边抽屉 149 | if(drawerSide == MMDrawerSideLeft){ 150 | sideDrawerViewController = drawerController.leftDrawerViewController; 151 | } 152 | else if(drawerSide == MMDrawerSideRight){ 153 | sideDrawerViewController = drawerController.rightDrawerViewController; 154 | } 155 | //设置 alpha 值 156 | [sideDrawerViewController.view setAlpha:percentVisible]; 157 | }]; 158 | ``` 159 | 160 | 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). 161 | 162 | 除此之外, 框架提供的一些抽屉动画会让你疯狂, 这些都是项目的补充, 更多信息继续往下看 163 | 164 | 165 | ###Center View Controller Interaction Mode 166 | When a drawer is open, you can control how a user can interact with the center view controller. 167 | 168 | ###中间 视图控制器的交互 169 | 当抽屉已经打开, 你可以控制中间 viewController 的交互模式 170 | 171 | * **MMDrawerOpenCenterInteractionModeNone**: The user can not interact with any content in the center view. 172 | * **MMDrawerOpenCenterInteractionModeFull**: The user can interact with all content in the center view. 173 | * **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. 174 | 175 | --- 176 | 177 | * **MMDrawerOpenCenterInteractionModeNone**: 中间的控制器不会有任何交互 178 | * **MMDrawerOpenCenterInteractionModeFull**: 中间控制器 交互打开 179 | * **MMDrawerOpenCenterInteractionModeNavigationBarOnly**: 仅仅只有中间控制器的 导航栏交互打开, 也就是菜单按钮可以响应, 允许你点击菜单按钮关闭抽屉. 默认设置 180 | 181 | 182 | ###Accessing the Drawer Controller from a Child View Controller 183 | You can use the `UIViewController+MMDrawerController` category in order to query the drawerController directly from child view controllers. 184 | 185 | ###从子控制器获取抽屉控制器 186 | 可以使用 `UIViewController+MMDrawerController` 分类 来查询 子控制器 的 抽屉控制器 187 | 188 | ###State Restoration 189 | 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. 190 | 191 | ### 状态重用 192 | 从0.4.0 版本开始 `MMDrawerController` 支持重用状态, 为了选择 `MMDrawerController` 的重用状态, 你必须设置抽屉控制器的 重用标志`restorationIdentifier` , `centerViewController`, `leftDrawerViewController` 和 `rightDrawerViewController`的实例也要设置重用标志, 这样当你的抽屉为打开状态下, 程序进入后台 抽屉的打开状态将会被储存. 193 | 194 | ##iOS 7 Status Bar Support 195 | ###Child View Controller Support 196 | 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. 197 | 198 | ## iOS 7 状态栏 支持 199 | 200 | ### iOS7 之后 子控制器开始支持状态栏, 默认情况下, 子视图控制器确定状态栏的情况, 包含状态栏的样式和是否影藏, 状态栏的样式会随着抽屉的开关状态而随这改变,也就是说 抽屉的状态栏可以和中间视图控制器的状态栏不一样 201 | 202 | 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. 203 | 204 | 如果你不想抽屉控制器拥有额外的状态栏, 你应该继承 `MMDrawerController` 重写方法 `childViewControllerForStatusBarStyle` and `childViewControllerForStatusBarHidden` 都返回 nil 205 | 206 | ###Custom Status Bar Background View 207 | 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. 208 | 209 | 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. 210 | 211 | 212 | ### 自定义 状态栏的背景视图 213 | 214 | 如果你的中间控制器和抽屉控制器 拥有不同的颜色风格, iOS 7 之后的状态栏可能表现的跟你想象的不太一样, iOS 7 之后, `MMDrawerController` 支持抽屉控制器有一个自定义状态栏, 提供给你一个区域去呈现特性颜色的状态栏,允许你在状态栏下绘制自定义内容不用担心 状态栏下面的导航栏的颜色会发生变化(iOS 7 之后 状态栏颜色会影响导航栏颜色 反之亦然) 这里使用了 iOS 6 之前的状态栏行为(iOS 6 之前 导航栏 和 状态栏互不影响, 这里采用了 iOS 6 的设计方式) 215 | --- 216 | ##Subclassing 217 | 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. 218 | 219 | 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. 220 | 221 | 222 | ## 继承 223 | 如果你打算继承 `MMDrawerController` 引入 类 `MMDrawerController+Subclass.h` 到你继承的类中 方便获取 `MMDrawerController.` 的私有方法, 注意: 有些方法需要你 调用 super 的方法, 请遵守下面的 规则 224 | 225 | 如果你需要这个框架支持更多的 方法, 请在 Github 上告诉我们, 我们将会帮你提供这些方法. 226 | 227 | --- 228 | ##Bells and Whistles 229 | A few extras to make your life easier... 230 | 231 | 下面的扩展会让你的工程 更容易. 232 | 233 | ###MMDrawerBarButtonItem 234 | 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. 235 | 236 | 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. 237 | 238 | 我们提供了 `UINavigationBar` 类型的菜单按钮, 你可以设置任意你想要的颜色 239 | 240 | 在 iOS 7 之后, 改变颜色的方法 被废弃, 你应该使用 `tintColor.` 来改变颜色, 注意 shadow 方法也被 废弃 241 | ###Prebuilt Example Animations 242 | 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. 243 | 244 | For example, if you wanted to use a slide and scale animation, you would do the following: 245 | 246 | 247 | 提供几种抽屉动画 248 | 为了让你更 简单去使用这个 库 , 我们提供了 几种抽屉动画, 你可以在 `MMDrawerVisualStates` 类中找到这些动画 249 | 250 | 例如: 你想用一个 侧边变形的动画 , 可以使用下面的代码. 251 | ```Objective-C 252 | [drawerController setDrawerVisualStateBlock:[MMDrawerVisualState slideAndScaleVisualStateBlock]]; 253 | ``` 254 | 255 | And that's it... 256 | 257 | Here's a quick list of the built in animations: 258 | 259 | 下面列出来 抽屉动画类型 260 | 261 | * **Slide**: The drawer slides at the same rate as the center view controller. 262 | * **Slide and Scale**: The drawer slides and scales up at the same time, while also alpha'ing from 0.0 to 1.0. 263 | * **Swinging Door**: The drawer swings in along a hinge on the center view controller. 264 | * **Parallax**: The drawer slides in at a slower rate than the center view controller, giving a parallax effect. 265 | 266 | --- 267 | * **Slide**: 侧边 抽屉动画 , 和 中间的控制器有着相同的长宽比 268 | * **Slide and Scale**: 侧边抽屉 变形动画, 同时 透明度 由 0.0 到 1.0 269 | * **Swinging Door**: The drawer swings in along a hinge on the center view controller. 270 | * **Parallax**: 一个视觉差 的动画 271 | 272 | ###Stretchy Drawer 273 | 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 274 | 275 | 弹性 抽屉 276 | 默认情况,当侧边抽屉被用户滑动展开超出了 最大宽度, 将会有一个有弹性的像话, 可以设置 `shouldStretchDrawer` 去关闭 这个效果, 你也可以自定义自己的弹性动画 277 | 278 | ###Bounce Preview 279 | 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. 280 | 281 | If you would like to bounce a custom distance, you can use `bouncePreviewForDrawerSide:distance:completion:`. 282 | 283 | 弹跳 视图 284 | 在用户第一次打开 APP 你可以使用弹跳效果向用户展示抽屉中的内容,方法 `bouncePreviewForDrawerSide:completion:` 让你方便的实现这个效果 285 | 286 | ###Nifty Example 287 | We decided to spruce up the example a bit using graphics generated from PaintCode. Hope you like it. 288 | 289 | The example shows off all the features of the library. Give it a whirl. 290 | 291 | --- 292 | ##What this Library Doesn't Do 293 | 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: 294 | 295 | 这个框架做不到下面的事情, 为了保证这个库 轻体量, 我们不得不做一些设计上的权衡, 我们决定 这个库不支持下面的事情 296 | 297 | * Top or bottom drawer views 298 | * Displaying both drawers at one time 299 | * Displaying a minimum drawer width 300 | * Support container view controllers other than `UINavigationController` (such as `UITabBarController` or `UISplitViewController`) as the center view controller. 301 | * Support presenting the drawer above the center view controller (like the Google+ app). 302 | 303 | * 不支持 顶部和底部 抽屉 304 | * 不支持同时 展示 两侧的抽屉 305 | * 不支持 最小抽屉宽度 306 | * 不支持 容器控制器作为 中间的控制器 比如 `UITabBarController` `UISplitViewController` (但是 `UINavigationController` 除外) 307 | * 不支持 在中间控制器上面 展示抽屉 (比如类似 Google+ app 的效果). 308 | 309 | We're sure this list will grow over time. But that's the cost of keeping something maintainable :) 310 | 311 | 我们 确保 长时间 都不会支持上面提到的这些事情 312 | 313 | --- 314 | ##Workarounds/FAQs 315 | ####How do I support editing/dragging cells in a tableview in the center view controller? 316 | 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)) 317 | 318 | 当 中间控制器含有一个 tablview 列表 时 ,怎么实现 cell 的编辑和拖拽效果呢? 319 | 最好的做法就是 当你开始编辑cell 时 把抽屉的打开/关闭手势设置为 `MMOpenDrawerGestureModeNone` / `MMCloseDrawerGestureModeNone` , 编辑结束后 保存 编辑结束的状态, 这样就确保了不影响 table view 的手势 , 320 | 321 | --- 322 | ## 翻译结束, 水平有限 有错误大家 及时指出啊, 在用这个库 有任何疑问可以咨询我啊 323 | 324 | ## 我的简书地址[iOS_愛OS](http://www.jianshu.com/u/6b0da6cb659c) 有问题可以给我发简信 , 基本上 每天都在线的 325 | 326 | --- 327 | ##Credit 328 | Designed and Developed by these fine folks at [Mutual Mobile](http://mutualmobile.com): 329 | 330 | ###Development 331 | 332 | * [Kevin Harwood](http://twitter.com/kevinharwood) 333 | * [Lars Anderson](http://twitter.com/theonlylars) 334 | * [Rene Cacheaux](http://twitter.com/rcachatx) 335 | * [Conrad Stoll](http://twitter.com/conradstoll) 336 | 337 | ###Design 338 | 339 | * [Matt McDaniel](http://twitter.com/supermattzor) 340 | 341 | --- 342 | ##Feedback 343 | We'd love to hear feedback on the library. Create Github issues, or hit us up on Twitter. 344 | 345 | --- 346 | ##License 347 | `MMDrawerController` is available under the MIT license. See the LICENSE file for more info. 348 | --------------------------------------------------------------------------------