├── KitchenSink
├── ExampleFiles
│ ├── en.lproj
│ │ └── InfoPlist.strings
│ ├── MMDrawerControllerKitchenSink-Prefix.pch
│ ├── MMLogoView.h
│ ├── MMCenterTableViewCell.h
│ ├── MMNavigationController.h
│ ├── MMSideDrawerTableViewCell.h
│ ├── MMExampleViewController.h
│ ├── MMAppDelegate.h
│ ├── MMSideDrawerSectionHeaderView.h
│ ├── MMExampleLeftSideDrawerViewController.h
│ ├── MMExampleRightSideDrawerViewController.h
│ ├── main.m
│ ├── MMExampleCenterTableViewController.h
│ ├── MMTableViewCell.h
│ ├── MMNavigationController.m
│ ├── MMExampleSideDrawerViewController.h
│ ├── MMExampleDrawerVisualStateManager.h
│ ├── MMCenterTableViewCell.m
│ ├── MMDrawerControllerKitchenSink-Info.plist
│ ├── MMExampleViewController.m
│ ├── MMSideDrawerTableViewCell.m
│ ├── MMSideDrawerSectionHeaderView.m
│ ├── LaunchScreen.xib
│ ├── MMExampleRightSideDrawerViewController.m
│ ├── MMExampleLeftSideDrawerViewController.m
│ ├── MMExampleDrawerVisualStateManager.m
│ ├── MMAppDelegate.m
│ ├── MMTableViewCell.m
│ ├── MMExampleCenterTableViewController.m
│ ├── MMExampleSideDrawerViewController.m
│ └── MMLogoView.m
├── Icons
│ ├── Icon.png
│ ├── Icon-72.png
│ ├── Icon@2x.png
│ └── Icon-72@2x.png
└── MMDrawerControllerKitchenSink.xcodeproj
│ ├── project.xcworkspace
│ ├── contents.xcworkspacedata
│ └── xcshareddata
│ │ └── MMDrawerControllerKitchenSink.xccheckout
│ └── xcshareddata
│ └── xcschemes
│ └── MMDrawerControllerKitchenSink.xcscheme
├── .travis.yml
├── .gitignore
├── LICENSE
├── MMDrawerController.podspec
├── MMDrawerController
├── UIViewController+MMDrawerController.h
├── UIViewController+MMDrawerController.m
├── MMDrawerVisualState.h
├── MMDrawerBarButtonItem.h
├── MMDrawerController+Subclass.h
├── MMDrawerVisualState.m
└── MMDrawerBarButtonItem.m
├── CHANGELOG.md
└── README.md
/KitchenSink/ExampleFiles/en.lproj/InfoPlist.strings:
--------------------------------------------------------------------------------
1 | /* Localized versions of Info.plist keys */
2 |
3 |
--------------------------------------------------------------------------------
/KitchenSink/Icons/Icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mutualmobile/MMDrawerController/HEAD/KitchenSink/Icons/Icon.png
--------------------------------------------------------------------------------
/KitchenSink/Icons/Icon-72.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mutualmobile/MMDrawerController/HEAD/KitchenSink/Icons/Icon-72.png
--------------------------------------------------------------------------------
/KitchenSink/Icons/Icon@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mutualmobile/MMDrawerController/HEAD/KitchenSink/Icons/Icon@2x.png
--------------------------------------------------------------------------------
/KitchenSink/Icons/Icon-72@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mutualmobile/MMDrawerController/HEAD/KitchenSink/Icons/Icon-72@2x.png
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 | language: objective-c
2 | script: xcodebuild -project KitchenSink/MMDrawerControllerKitchenSink.xcodeproj/ -scheme MMDrawerControllerKitchenSink -sdk iphonesimulator ONLY_ACTIVE_ARCH=NO
--------------------------------------------------------------------------------
/KitchenSink/MMDrawerControllerKitchenSink.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/.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 |
--------------------------------------------------------------------------------
/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
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/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/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/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/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/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/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/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/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 | @interface MMExampleLeftSideDrawerViewController : MMExampleSideDrawerViewController
25 |
26 | @end
27 |
--------------------------------------------------------------------------------
/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 | @interface MMExampleRightSideDrawerViewController : MMExampleSideDrawerViewController
24 |
25 | @end
26 |
--------------------------------------------------------------------------------
/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/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 | @interface MMExampleCenterTableViewController : MMExampleViewController
26 | @property (nonatomic,strong) UITableView * tableView;
27 |
28 | @end
29 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/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/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/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/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 | typedef NS_ENUM(NSInteger, MMDrawerAnimationType){
26 | MMDrawerAnimationTypeNone,
27 | MMDrawerAnimationTypeSlide,
28 | MMDrawerAnimationTypeSlideAndScale,
29 | MMDrawerAnimationTypeSwingingDoor,
30 | MMDrawerAnimationTypeParallax,
31 | };
32 |
33 | @interface MMExampleDrawerVisualStateManager : NSObject
34 |
35 | @property (nonatomic,assign) MMDrawerAnimationType leftDrawerAnimationType;
36 | @property (nonatomic,assign) MMDrawerAnimationType rightDrawerAnimationType;
37 |
38 | + (MMExampleDrawerVisualStateManager *)sharedManager;
39 |
40 | -(MMDrawerControllerDrawerVisualStateBlock)drawerVisualStateBlockForDrawerSide:(MMDrawerSide)drawerSide;
41 |
42 | @end
43 |
--------------------------------------------------------------------------------
/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/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 | [[NSNotificationCenter defaultCenter]
42 | addObserver:self
43 | selector:@selector(contentSizeDidChangeNotification:)
44 | name:UIContentSizeCategoryDidChangeNotification
45 | object:nil];
46 | }
47 |
48 | - (void)dealloc{
49 | [[NSNotificationCenter defaultCenter]
50 | removeObserver:self];
51 | }
52 |
53 | -(void)contentSizeDidChangeNotification:(NSNotification*)notification{
54 | [self contentSizeDidChange:notification.userInfo[UIContentSizeCategoryNewValueKey]];
55 | }
56 |
57 | -(void)contentSizeDidChange:(NSString *)size{
58 | //Implement in subclass
59 | }
60 |
61 | @end
62 |
--------------------------------------------------------------------------------
/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 | */
38 | @property(nonatomic, strong, readonly) MMDrawerController *mm_drawerController;
39 |
40 | /**
41 | 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`
42 | */
43 | @property(nonatomic, assign, readonly) CGRect mm_visibleDrawerFrame;
44 |
45 | @end
46 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/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 | @interface MMDrawerBarButtonItem : UIBarButtonItem
28 |
29 | ///---------------------------------------
30 | /// @name Initializing a `MMDrawerBarButtonItem`
31 | ///---------------------------------------
32 |
33 | /**
34 | Creates and initializes an `MMDrawerBarButtonItem` without a border.
35 |
36 | @param target The target to forward the `action` to when the button is pressed.
37 | @param action The action to call when the button is pressed.
38 |
39 | @return The newly-initialized bar button item.
40 | */
41 | -(instancetype)initWithTarget:(id)target action:(SEL)action;
42 |
43 | /**
44 | Returns the current color of the menu button for the state requested. This property is deprecated in iOS 7.0. Use `tintColor` instead.
45 |
46 | @param state The UIControl state that the color is being requested for.
47 |
48 | @return The menu button color for the requested state.
49 | */
50 | -(UIColor *)menuButtonColorForState:(UIControlState)state __attribute__((deprecated("Use tintColor instead")));
51 |
52 | /**
53 | 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.
54 |
55 | @param color The color to set.
56 | @param state The state to set the color for.
57 | */
58 | -(void)setMenuButtonColor:(UIColor *)color forState:(UIControlState)state __attribute__((deprecated("Use tintColor instead")));
59 |
60 | /**
61 | 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.
62 |
63 | @param state The UIControl state that the color is being requested for.
64 |
65 | @return The menu button color for the requested state.
66 | */
67 | -(UIColor *)shadowColorForState:(UIControlState)state __attribute__((deprecated("Shadow is no longer supported")));
68 |
69 | /**
70 | 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.
71 |
72 | @param color The color to set.
73 | @param state The state to set the color for.
74 | */
75 | -(void)setShadowColor:(UIColor *)color forState:(UIControlState)state __attribute__((deprecated("Shadow is no longer supported")));
76 |
77 | @end
78 |
--------------------------------------------------------------------------------
/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/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/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/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/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 | MMDrawerAnimationType animationType;
42 | if(drawerSide == MMDrawerSideLeft){
43 | animationType = self.leftDrawerAnimationType;
44 | }
45 | else {
46 | animationType = self.rightDrawerAnimationType;
47 | }
48 |
49 | MMDrawerControllerDrawerVisualStateBlock visualStateBlock = nil;
50 | switch (animationType) {
51 | case MMDrawerAnimationTypeSlide:
52 | visualStateBlock = [MMDrawerVisualState slideVisualStateBlock];
53 | break;
54 | case MMDrawerAnimationTypeSlideAndScale:
55 | visualStateBlock = [MMDrawerVisualState slideAndScaleVisualStateBlock];
56 | break;
57 | case MMDrawerAnimationTypeParallax:
58 | visualStateBlock = [MMDrawerVisualState parallaxVisualStateBlockWithParallaxFactor:2.0];
59 | break;
60 | case MMDrawerAnimationTypeSwingingDoor:
61 | visualStateBlock = [MMDrawerVisualState swingingDoorVisualStateBlock];
62 | break;
63 | default:
64 | visualStateBlock = ^(MMDrawerController * drawerController, MMDrawerSide drawerSide, CGFloat percentVisible){
65 |
66 | UIViewController * sideDrawerViewController;
67 | CATransform3D transform;
68 | CGFloat maxDrawerWidth;
69 |
70 | if(drawerSide == MMDrawerSideLeft){
71 | sideDrawerViewController = drawerController.leftDrawerViewController;
72 | maxDrawerWidth = drawerController.maximumLeftDrawerWidth;
73 | }
74 | else if(drawerSide == MMDrawerSideRight){
75 | sideDrawerViewController = drawerController.rightDrawerViewController;
76 | maxDrawerWidth = drawerController.maximumRightDrawerWidth;
77 | }
78 |
79 | if(percentVisible > 1.0){
80 | transform = CATransform3DMakeScale(percentVisible, 1.f, 1.f);
81 |
82 | if(drawerSide == MMDrawerSideLeft){
83 | transform = CATransform3DTranslate(transform, maxDrawerWidth*(percentVisible-1.f)/2, 0.f, 0.f);
84 | }else if(drawerSide == MMDrawerSideRight){
85 | transform = CATransform3DTranslate(transform, -maxDrawerWidth*(percentVisible-1.f)/2, 0.f, 0.f);
86 | }
87 | }
88 | else {
89 | transform = CATransform3DIdentity;
90 | }
91 | [sideDrawerViewController.view.layer setTransform:transform];
92 | };
93 | break;
94 | }
95 | return visualStateBlock;
96 | }
97 | @end
98 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/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 | UIViewController * leftSideDrawerViewController = [[MMExampleLeftSideDrawerViewController alloc] init];
42 |
43 | UIViewController * centerViewController = [[MMExampleCenterTableViewController alloc] init];
44 |
45 | UIViewController * rightSideDrawerViewController = [[MMExampleRightSideDrawerViewController alloc] init];
46 |
47 | UINavigationController * navigationController = [[MMNavigationController alloc] initWithRootViewController:centerViewController];
48 | [navigationController setRestorationIdentifier:@"MMExampleCenterNavigationControllerRestorationKey"];
49 | UINavigationController * rightSideNavController = [[MMNavigationController alloc] initWithRootViewController:rightSideDrawerViewController];
50 | [rightSideNavController setRestorationIdentifier:@"MMExampleRightNavigationControllerRestorationKey"];
51 | UINavigationController * leftSideNavController = [[MMNavigationController alloc] initWithRootViewController:leftSideDrawerViewController];
52 | [leftSideNavController setRestorationIdentifier:@"MMExampleLeftNavigationControllerRestorationKey"];
53 | self.drawerController = [[MMDrawerController alloc]
54 | initWithCenterViewController:navigationController
55 | leftDrawerViewController:leftSideNavController
56 | rightDrawerViewController:rightSideNavController];
57 | [self.drawerController setShowsShadow:NO];
58 | [self.drawerController setRestorationIdentifier:@"MMDrawer"];
59 | [self.drawerController setMaximumRightDrawerWidth:200.0];
60 | [self.drawerController setOpenDrawerGestureModeMask:MMOpenDrawerGestureModeAll];
61 | [self.drawerController setCloseDrawerGestureModeMask:MMCloseDrawerGestureModeAll];
62 |
63 | [self.drawerController
64 | setDrawerVisualStateBlock:^(MMDrawerController *drawerController, MMDrawerSide drawerSide, CGFloat percentVisible) {
65 | MMDrawerControllerDrawerVisualStateBlock block;
66 | block = [[MMExampleDrawerVisualStateManager sharedManager]
67 | drawerVisualStateBlockForDrawerSide:drawerSide];
68 | if(block){
69 | block(drawerController, drawerSide, percentVisible);
70 | }
71 | }];
72 | self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
73 |
74 | UIColor * tintColor = [UIColor colorWithRed:29.0/255.0
75 | green:173.0/255.0
76 | blue:234.0/255.0
77 | alpha:1.0];
78 | [self.window setTintColor:tintColor];
79 | [self.window setRootViewController:self.drawerController];
80 |
81 | return YES;
82 | }
83 |
84 |
85 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
86 | {
87 | self.window.backgroundColor = [UIColor whiteColor];
88 | [self.window makeKeyAndVisible];
89 |
90 | return YES;
91 | }
92 |
93 | - (BOOL)application:(UIApplication *)application shouldSaveApplicationState:(NSCoder *)coder{
94 | return YES;
95 | }
96 |
97 | - (BOOL)application:(UIApplication *)application shouldRestoreApplicationState:(NSCoder *)coder{
98 | return YES;
99 | }
100 |
101 | - (UIViewController *)application:(UIApplication *)application viewControllerWithRestorationIdentifierPath:(NSArray *)identifierComponents coder:(NSCoder *)coder
102 | {
103 | NSString * key = [identifierComponents lastObject];
104 | if([key isEqualToString:@"MMDrawer"]){
105 | return self.window.rootViewController;
106 | }
107 | else if ([key isEqualToString:@"MMExampleCenterNavigationControllerRestorationKey"]) {
108 | return ((MMDrawerController *)self.window.rootViewController).centerViewController;
109 | }
110 | else if ([key isEqualToString:@"MMExampleRightNavigationControllerRestorationKey"]) {
111 | return ((MMDrawerController *)self.window.rootViewController).rightDrawerViewController;
112 | }
113 | else if ([key isEqualToString:@"MMExampleLeftNavigationControllerRestorationKey"]) {
114 | return ((MMDrawerController *)self.window.rootViewController).leftDrawerViewController;
115 | }
116 | else if ([key isEqualToString:@"MMExampleLeftSideDrawerController"]){
117 | UIViewController * leftVC = ((MMDrawerController *)self.window.rootViewController).leftDrawerViewController;
118 | if([leftVC isKindOfClass:[UINavigationController class]]){
119 | return [(UINavigationController*)leftVC topViewController];
120 | }
121 | else {
122 | return leftVC;
123 | }
124 |
125 | }
126 | else if ([key isEqualToString:@"MMExampleRightSideDrawerController"]){
127 | UIViewController * rightVC = ((MMDrawerController *)self.window.rootViewController).rightDrawerViewController;
128 | if([rightVC isKindOfClass:[UINavigationController class]]){
129 | return [(UINavigationController*)rightVC topViewController];
130 | }
131 | else {
132 | return rightVC;
133 | }
134 | }
135 | return nil;
136 | }
137 |
138 | @end
139 |
--------------------------------------------------------------------------------
/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 | CGFloat distance = MAX(drawerController.maximumLeftDrawerWidth,drawerController.visibleLeftDrawerWidth);
125 | if (percentVisible <= 1.f) {
126 | transform = CATransform3DMakeTranslation((-distance)/parallaxFactor+(distance*percentVisible/parallaxFactor), 0.0, 0.0);
127 | }
128 | else{
129 | transform = CATransform3DMakeScale(percentVisible, 1.f, 1.f);
130 | transform = CATransform3DTranslate(transform, drawerController.maximumLeftDrawerWidth*(percentVisible-1.f)/2, 0.f, 0.f);
131 | }
132 | }
133 | else if(drawerSide == MMDrawerSideRight){
134 | sideDrawerViewController = drawerController.rightDrawerViewController;
135 | CGFloat distance = MAX(drawerController.maximumRightDrawerWidth,drawerController.visibleRightDrawerWidth);
136 | if(percentVisible <= 1.f){
137 | transform = CATransform3DMakeTranslation((distance)/parallaxFactor-(distance*percentVisible)/parallaxFactor, 0.0, 0.0);
138 | }
139 | else{
140 | transform = CATransform3DMakeScale(percentVisible, 1.f, 1.f);
141 | transform = CATransform3DTranslate(transform, -drawerController.maximumRightDrawerWidth*(percentVisible-1.f)/2, 0.f, 0.f);
142 | }
143 | }
144 |
145 | [sideDrawerViewController.view.layer setTransform:transform];
146 | };
147 | return visualStateBlock;
148 | }
149 |
150 | @end
151 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/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 |
5 |
6 |
7 |
8 |
9 | ---
10 | ##Documentation
11 | Official appledoc documentation can be found at [CocoaDocs](http://cocoadocs.org/docsets/MMDrawerController/).
12 |
13 | ---
14 | ##Installing MMDrawerController
15 |
16 | You can install MMDrawerController in your project by using [CocoaPods](https://github.com/cocoapods/cocoapods):
17 |
18 | ```Ruby
19 | pod 'MMDrawerController', '~> 0.5.7'
20 | ```
21 |
22 | ---
23 | ##Creating a Drawer Controller
24 | Creating a `MMDrawerController` is as easy as creating a center view controller and the drawer view controllers, and init'ing the drawer.
25 |
26 | ```Objective-C
27 | UIViewController * leftDrawer = [[UIViewController alloc] init];
28 | UIViewController * center = [[UIViewController alloc] init];
29 | UIViewController * rightDrawer = [[UIViewController alloc] init];
30 |
31 | MMDrawerController * drawerController = [[MMDrawerController alloc]
32 | initWithCenterViewController:center
33 | leftDrawerViewController:leftDrawer
34 | rightDrawerViewController:rightDrawer];
35 | ```
36 |
37 | ---
38 | ##Features
39 |
40 | ###UINavigationController Support
41 | `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).
42 |
43 | ###UIGestureRecognizer Support
44 | `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:
45 |
46 | * **MMOpenDrawerGestureMode**
47 | * **MMOpenDrawerGestureModePanningNavigationBar**: The user can open the drawer by panning anywhere on the navigation bar.
48 | * **MMOpenDrawerGestureModePanningCenterView**: The user can open the drawer by panning anywhere on the center view.
49 | * **MMOpenDrawerGestureModeBezelPanningCenterView**: The user can open the drawer by starting a pan anywhere within 20 points of the bezel.
50 | * **MMOpenDrawerGestureModeCustom**: The developer can provide a callback block to determine if the gesture should be recognized. More information below.
51 |
52 | * **MMCloseDrawerGestureMode**
53 | * **MMCloseDrawerGestureModePanningNavigationBar**: The user can close the drawer by panning anywhere on the navigation bar.
54 | * **MMCloseDrawerGestureModePanningCenterView**: The user can close the drawer by panning anywhere on the center view.
55 | * **MMCloseDrawerGestureModeBezelPanningCenterView**: The user can close the drawer by starting a pan anywhere within the bezel of the center view.
56 | * **MMCloseDrawerGestureModeTapNavigationBar**: The user can close the drawer by tapping the navigation bar.
57 | * **MMCloseDrawerGestureModeTapCenterView**: The user can close the drawer by tapping the center view.
58 | * **MMCloseDrawerGestureModePanningDrawerView**: The user can close the drawer by panning anywhere on the drawer view.
59 | * **MMCloseDrawerGestureModeCustom**: The developer can provide a callback block to determine if the gesture should be recognized. More information below.
60 |
61 | 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.
62 |
63 | ####Custom Gesture Recognizer Support
64 | 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.
65 |
66 | 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:
67 |
68 | ```Objective-C
69 | [myDrawerController
70 | setGestureShouldRecognizeTouchBlock:^BOOL(MMDrawerController *drawerController, UIGestureRecognizer *gesture, UITouch *touch) {
71 | BOOL shouldRecognizeTouch = NO;
72 | if(drawerController.openSide == MMDrawerSideNone &&
73 | [gesture isKindOfClass:[UIPanGestureRecognizer class]]){
74 | UIView * customView = [drawerController.centerViewController myCustomSubview];
75 | CGPoint location = [touch locationInView:customView];
76 | shouldRecognizeTouch = (CGRectContainsPoint(customView.bounds, location));
77 | }
78 | return shouldRecognizeTouch;
79 | }];
80 | ```
81 | 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.
82 |
83 | ###Custom Drawer Open/Close Animations
84 | `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.
85 |
86 | For example, to set the alpha of the side drawer controller from 0 to 1 during an animation, you would do the following:
87 |
88 | ```Objective-C
89 | [drawerController
90 | setDrawerVisualStateBlock:^(MMDrawerController *drawerController, MMDrawerSide drawerSide, CGFloat percentVisible) {
91 | UIViewController * sideDrawerViewController;
92 | if(drawerSide == MMDrawerSideLeft){
93 | sideDrawerViewController = drawerController.leftDrawerViewController;
94 | }
95 | else if(drawerSide == MMDrawerSideRight){
96 | sideDrawerViewController = drawerController.rightDrawerViewController;
97 | }
98 | [sideDrawerViewController.view setAlpha:percentVisible];
99 | }];
100 | ```
101 |
102 | 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).
103 |
104 | ###Center View Controller Interaction Mode
105 | When a drawer is open, you can control how a user can interact with the center view controller.
106 |
107 | * **MMDrawerOpenCenterInteractionModeNone**: The user can not interact with any content in the center view.
108 | * **MMDrawerOpenCenterInteractionModeFull**: The user can interact with all content in the center view.
109 | * **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.
110 |
111 | ###Accessing the Drawer Controller from a Child View Controller
112 | You can use the `UIViewController+MMDrawerController` category in order to query the drawerController directly from child view controllers.
113 |
114 | ###State Restoration
115 | 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.
116 |
117 | ##iOS 7 Status Bar Support
118 | ###Child View Controller Support
119 | 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.
120 |
121 | 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.
122 |
123 | ###Custom Status Bar Background View
124 | 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.
125 |
126 | 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.
127 |
128 | ---
129 | ##Subclassing
130 | 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.
131 |
132 | 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.
133 |
134 | ---
135 | ##Bells and Whistles
136 | A few extras to make your life easier...
137 |
138 | ###MMDrawerBarButtonItem
139 | 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.
140 |
141 | 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.
142 |
143 | ###Prebuilt Example Animations
144 | 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.
145 |
146 | For example, if you wanted to use a slide and scale animation, you would do the following:
147 |
148 | ```Objective-C
149 | [drawerController setDrawerVisualStateBlock:[MMDrawerVisualState slideAndScaleVisualStateBlock]];
150 | ```
151 |
152 | And that's it...
153 |
154 | Here's a quick list of the built in animations:
155 |
156 | * **Slide**: The drawer slides at the same rate as the center view controller.
157 | * **Slide and Scale**: The drawer slides and scales up at the same time, while also alpha'ing from 0.0 to 1.0.
158 | * **Swinging Door**: The drawer swings in along a hinge on the center view controller.
159 | * **Parallax**: The drawer slides in at a slower rate than the center view controller, giving a parallax effect.
160 |
161 | ###Stretchy Drawer
162 | 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
163 |
164 | ###Bounce Preview
165 | 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.
166 |
167 | If you would like to bounce a custom distance, you can use `bouncePreviewForDrawerSide:distance:completion:`.
168 |
169 | ###Nifty Example
170 | We decided to spruce up the example a bit using graphics generated from PaintCode. Hope you like it.
171 |
172 | The example shows off all the features of the library. Give it a whirl.
173 |
174 | ---
175 | ##What this Library Doesn't Do
176 | 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:
177 |
178 | * Top or bottom drawer views
179 | * Displaying both drawers at one time
180 | * Displaying a minimum drawer width
181 | * Support container view controllers other than `UINavigationController` (such as `UITabBarController` or `UISplitViewController`) as the center view controller.
182 | * Support presenting the drawer above the center view controller (like the Google+ app).
183 |
184 | We're sure this list will grow over time. But that's the cost of keeping something maintainable :)
185 |
186 | ---
187 | ##Workarounds/FAQs
188 | ####How do I support editing/dragging cells in a tableview in the center view controller?
189 | 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))
190 |
191 |
192 | ---
193 | ##Credit
194 | Designed and Developed by these fine folks at [Mutual Mobile](http://mutualmobile.com):
195 |
196 | ###Development
197 |
198 | * [Kevin Harwood](http://twitter.com/kevinharwood)
199 | * [Lars Anderson](http://twitter.com/theonlylars)
200 | * [Rene Cacheaux](http://twitter.com/rcachatx)
201 | * [Conrad Stoll](http://twitter.com/conradstoll)
202 |
203 | ###Design
204 |
205 | * [Matt McDaniel](http://twitter.com/supermattzor)
206 |
207 | ---
208 | ##Feedback
209 | We'd love to hear feedback on the library. Create Github issues, or hit us up on Twitter.
210 |
211 | ---
212 | ##License
213 | `MMDrawerController` is available under the MIT license. See the LICENSE file for more info.
214 |
--------------------------------------------------------------------------------
/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 | MMCenterViewControllerSectionLeftViewState,
36 | MMCenterViewControllerSectionLeftDrawerAnimation,
37 | MMCenterViewControllerSectionRightViewState,
38 | MMCenterViewControllerSectionRightDrawerAnimation,
39 | };
40 |
41 | @interface MMExampleCenterTableViewController ()
42 |
43 | @end
44 |
45 | @implementation MMExampleCenterTableViewController
46 |
47 | - (id)init
48 | {
49 | self = [super init];
50 | if (self) {
51 | [self setRestorationIdentifier:@"MMExampleCenterControllerRestorationKey"];
52 | }
53 | return self;
54 | }
55 |
56 | - (void)viewDidLoad
57 | {
58 | [super viewDidLoad];
59 |
60 | _tableView = [[UITableView alloc] initWithFrame:self.view.bounds style:UITableViewStyleGrouped];
61 | [self.tableView setDelegate:self];
62 | [self.tableView setDataSource:self];
63 | [self.view addSubview:self.tableView];
64 | [self.tableView setAutoresizingMask:UIViewAutoresizingFlexibleWidth|UIViewAutoresizingFlexibleHeight];
65 |
66 | UITapGestureRecognizer * doubleTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(doubleTap:)];
67 | [doubleTap setNumberOfTapsRequired:2];
68 | [self.view addGestureRecognizer:doubleTap];
69 |
70 | UITapGestureRecognizer * twoFingerDoubleTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(twoFingerDoubleTap:)];
71 | [twoFingerDoubleTap setNumberOfTapsRequired:2];
72 | [twoFingerDoubleTap setNumberOfTouchesRequired:2];
73 | [self.view addGestureRecognizer:twoFingerDoubleTap];
74 |
75 |
76 | [self setupLeftMenuButton];
77 | [self setupRightMenuButton];
78 |
79 | UIColor * barColor = [UIColor
80 | colorWithRed:247.0/255.0
81 | green:249.0/255.0
82 | blue:250.0/255.0
83 | alpha:1.0];
84 | [self.navigationController.navigationBar setBarTintColor:barColor];
85 |
86 |
87 | MMLogoView * logo = [[MMLogoView alloc] initWithFrame:CGRectMake(0, 0, 29, 31)];
88 | [self.navigationItem setTitleView:logo];
89 | [self.navigationController.view.layer setCornerRadius:10.0f];
90 |
91 |
92 | UIView *backView = [[UIView alloc] init];
93 | [backView setBackgroundColor:[UIColor colorWithRed:208.0/255.0
94 | green:208.0/255.0
95 | blue:208.0/255.0
96 | alpha:1.0]];
97 | [self.tableView setBackgroundView:backView];
98 | }
99 |
100 | -(void)viewWillAppear:(BOOL)animated{
101 | [super viewWillAppear:animated];
102 | NSLog(@"Center will appear");
103 | }
104 |
105 | -(void)viewDidAppear:(BOOL)animated{
106 | [super viewDidAppear:animated];
107 | NSLog(@"Center did appear");
108 | }
109 |
110 | -(void)viewWillDisappear:(BOOL)animated{
111 | [super viewWillDisappear:animated];
112 | NSLog(@"Center will disappear");
113 | }
114 |
115 | -(void)viewDidDisappear:(BOOL)animated{
116 | [super viewDidDisappear:animated];
117 | NSLog(@"Center did disappear");
118 | }
119 |
120 | -(void)setupLeftMenuButton{
121 | MMDrawerBarButtonItem * leftDrawerButton = [[MMDrawerBarButtonItem alloc] initWithTarget:self action:@selector(leftDrawerButtonPress:)];
122 | [self.navigationItem setLeftBarButtonItem:leftDrawerButton animated:YES];
123 | }
124 |
125 | -(void)setupRightMenuButton{
126 | MMDrawerBarButtonItem * rightDrawerButton = [[MMDrawerBarButtonItem alloc] initWithTarget:self action:@selector(rightDrawerButtonPress:)];
127 | [self.navigationItem setRightBarButtonItem:rightDrawerButton animated:YES];
128 | }
129 |
130 | -(void)contentSizeDidChange:(NSString *)size{
131 | [self.tableView reloadData];
132 | }
133 |
134 | #pragma mark - Table view data source
135 |
136 | - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
137 | {
138 | return 4;
139 | }
140 |
141 | - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
142 | {
143 | // Return the number of rows in the section.
144 | switch (section) {
145 | case MMCenterViewControllerSectionLeftDrawerAnimation:
146 | case MMCenterViewControllerSectionRightDrawerAnimation:
147 | return 5;
148 | case MMCenterViewControllerSectionLeftViewState:
149 | case MMCenterViewControllerSectionRightViewState:
150 | return 1;
151 | default:
152 | return 0;
153 | }
154 | }
155 |
156 | - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
157 | {
158 | static NSString *CellIdentifier = @"Cell";
159 |
160 | UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
161 | if (cell == nil) {
162 |
163 | cell = [[MMCenterTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
164 | [cell setSelectionStyle:UITableViewCellSelectionStyleGray];
165 | }
166 |
167 | UIColor * selectedColor = [UIColor
168 | colorWithRed:1.0/255.0
169 | green:15.0/255.0
170 | blue:25.0/255.0
171 | alpha:1.0];
172 | UIColor * unselectedColor = [UIColor
173 | colorWithRed:79.0/255.0
174 | green:93.0/255.0
175 | blue:102.0/255.0
176 | alpha:1.0];
177 |
178 | switch (indexPath.section) {
179 | case MMCenterViewControllerSectionLeftDrawerAnimation:
180 | case MMCenterViewControllerSectionRightDrawerAnimation:{
181 | MMDrawerAnimationType animationTypeForSection;
182 | if(indexPath.section == MMCenterViewControllerSectionLeftDrawerAnimation){
183 | animationTypeForSection = [[MMExampleDrawerVisualStateManager sharedManager] leftDrawerAnimationType];
184 | }
185 | else {
186 | animationTypeForSection = [[MMExampleDrawerVisualStateManager sharedManager] rightDrawerAnimationType];
187 | }
188 |
189 | if(animationTypeForSection == indexPath.row){
190 | [cell setAccessoryType:UITableViewCellAccessoryCheckmark];
191 | [cell.textLabel setTextColor:selectedColor];
192 | }
193 | else {
194 | [cell setAccessoryType:UITableViewCellAccessoryNone];
195 | [cell.textLabel setTextColor:unselectedColor];
196 | }
197 | switch (indexPath.row) {
198 | case MMDrawerAnimationTypeNone:
199 | [cell.textLabel setText:@"None"];
200 | break;
201 | case MMDrawerAnimationTypeSlide:
202 | [cell.textLabel setText:@"Slide"];
203 | break;
204 | case MMDrawerAnimationTypeSlideAndScale:
205 | [cell.textLabel setText:@"Slide and Scale"];
206 | break;
207 | case MMDrawerAnimationTypeSwingingDoor:
208 | [cell.textLabel setText:@"Swinging Door"];
209 | break;
210 | case MMDrawerAnimationTypeParallax:
211 | [cell.textLabel setText:@"Parallax"];
212 | break;
213 | default:
214 | break;
215 | }
216 | break;
217 | }
218 | case MMCenterViewControllerSectionLeftViewState:{
219 | [cell.textLabel setText:@"Enabled"];
220 | if(self.mm_drawerController.leftDrawerViewController){
221 | [cell setAccessoryType:UITableViewCellAccessoryCheckmark];
222 | [cell.textLabel setTextColor:selectedColor];
223 | }
224 | else{
225 | [cell setAccessoryType:UITableViewCellAccessoryNone];
226 | [cell.textLabel setTextColor:unselectedColor];
227 | }
228 | break;
229 | }
230 | case MMCenterViewControllerSectionRightViewState:{
231 | [cell.textLabel setText:@"Enabled"];
232 | if(self.mm_drawerController.rightDrawerViewController){
233 | [cell setAccessoryType:UITableViewCellAccessoryCheckmark];
234 | [cell.textLabel setTextColor:selectedColor];
235 | }
236 | else{
237 | [cell setAccessoryType:UITableViewCellAccessoryNone];
238 | [cell.textLabel setTextColor:unselectedColor];
239 | }
240 | break;
241 | }
242 | default:
243 | break;
244 | }
245 |
246 | return cell;
247 | }
248 |
249 | -(NSString*)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section{
250 | switch (section) {
251 | case MMCenterViewControllerSectionLeftDrawerAnimation:
252 | return @"Left Drawer Animation";
253 | case MMCenterViewControllerSectionRightDrawerAnimation:
254 | return @"Right Drawer Animation";
255 | case MMCenterViewControllerSectionLeftViewState:
256 | return @"Left Drawer";
257 | case MMCenterViewControllerSectionRightViewState:
258 | return @"Right Drawer";
259 | default:
260 | return nil;
261 | }
262 | }
263 | #pragma mark - Table view delegate
264 |
265 | - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
266 | {
267 | switch (indexPath.section) {
268 | case MMCenterViewControllerSectionLeftDrawerAnimation:
269 | case MMCenterViewControllerSectionRightDrawerAnimation:{
270 | if(indexPath.section == MMCenterViewControllerSectionLeftDrawerAnimation){
271 | [[MMExampleDrawerVisualStateManager sharedManager] setLeftDrawerAnimationType:indexPath.row];
272 | }
273 | else {
274 | [[MMExampleDrawerVisualStateManager sharedManager] setRightDrawerAnimationType:indexPath.row];
275 | }
276 | [tableView reloadSections:[NSIndexSet indexSetWithIndex:indexPath.section] withRowAnimation:UITableViewRowAnimationNone];
277 | [tableView selectRowAtIndexPath:indexPath animated:NO scrollPosition:UITableViewScrollPositionNone];
278 | [tableView deselectRowAtIndexPath:indexPath animated:YES];
279 | break;
280 | }
281 | case MMCenterViewControllerSectionLeftViewState:
282 | case MMCenterViewControllerSectionRightViewState:{
283 | UIViewController * sideDrawerViewController;
284 | MMDrawerSide drawerSide = MMDrawerSideNone;
285 | if(indexPath.section == MMCenterViewControllerSectionLeftViewState){
286 | sideDrawerViewController = self.mm_drawerController.leftDrawerViewController;
287 | drawerSide = MMDrawerSideLeft;
288 | }
289 | else if(indexPath.section == MMCenterViewControllerSectionRightViewState){
290 | sideDrawerViewController = self.mm_drawerController.rightDrawerViewController;
291 | drawerSide = MMDrawerSideRight;
292 | }
293 |
294 | if(sideDrawerViewController){
295 | [self.mm_drawerController
296 | closeDrawerAnimated:YES
297 | completion:^(BOOL finished) {
298 | if(drawerSide == MMDrawerSideLeft){
299 | [self.mm_drawerController setLeftDrawerViewController:nil];
300 | [self.navigationItem setLeftBarButtonItems:nil animated:YES];
301 | }
302 | else if(drawerSide == MMDrawerSideRight){
303 | [self.mm_drawerController setRightDrawerViewController:nil];
304 | [self.navigationItem setRightBarButtonItem:nil animated:YES];
305 | }
306 | [tableView reloadRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationNone];
307 | [tableView selectRowAtIndexPath:indexPath animated:NO scrollPosition:UITableViewScrollPositionNone];
308 | [tableView deselectRowAtIndexPath:indexPath animated:YES];
309 | }];
310 |
311 | }
312 | else {
313 | if(drawerSide == MMDrawerSideLeft){
314 | UIViewController * vc = [[MMExampleLeftSideDrawerViewController alloc] init];
315 | UINavigationController * navC = [[MMNavigationController alloc] initWithRootViewController:vc];
316 | [self.mm_drawerController setLeftDrawerViewController:navC];
317 | [self setupLeftMenuButton];
318 |
319 | }
320 | else if(drawerSide == MMDrawerSideRight){
321 | UIViewController * vc = [[MMExampleRightSideDrawerViewController alloc] init];
322 | UINavigationController * navC = [[MMNavigationController alloc] initWithRootViewController:vc];
323 | [self.mm_drawerController setRightDrawerViewController:navC];
324 | [self setupRightMenuButton];
325 | }
326 | [tableView reloadRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationNone];
327 | [tableView selectRowAtIndexPath:indexPath animated:NO scrollPosition:UITableViewScrollPositionNone];
328 | [tableView deselectRowAtIndexPath:indexPath animated:YES];
329 | }
330 |
331 | break;
332 | }
333 | default:
334 | break;
335 | }
336 | }
337 |
338 | #pragma mark - Button Handlers
339 | -(void)leftDrawerButtonPress:(id)sender{
340 | [self.mm_drawerController toggleDrawerSide:MMDrawerSideLeft animated:YES completion:nil];
341 | }
342 |
343 | -(void)rightDrawerButtonPress:(id)sender{
344 | [self.mm_drawerController toggleDrawerSide:MMDrawerSideRight animated:YES completion:nil];
345 | }
346 |
347 | -(void)doubleTap:(UITapGestureRecognizer*)gesture{
348 | [self.mm_drawerController bouncePreviewForDrawerSide:MMDrawerSideLeft completion:nil];
349 | }
350 |
351 | -(void)twoFingerDoubleTap:(UITapGestureRecognizer*)gesture{
352 | [self.mm_drawerController bouncePreviewForDrawerSide:MMDrawerSideRight completion:nil];
353 | }
354 |
355 | @end
356 |
--------------------------------------------------------------------------------
/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/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 |
--------------------------------------------------------------------------------