├── .gitignore
├── LICENSE.md
├── Launch Screen.storyboard
├── MJNIndexForTableView.xcodeproj
├── project.pbxproj
├── project.xcworkspace
│ ├── contents.xcworkspacedata
│ └── xcuserdata
│ │ └── mat.xcuserdatad
│ │ ├── UserInterfaceState (Mateuszs-Mac-mini's conflicted copy 2013-07-12).xcuserstate
│ │ ├── UserInterfaceState.xcuserstate
│ │ └── WorkspaceSettings.xcsettings
└── xcuserdata
│ └── mat.xcuserdatad
│ ├── xcdebugger
│ ├── Breakpoints.xcbkptlist
│ └── Breakpoints_v2.xcbkptlist
│ └── xcschemes
│ ├── MJNIndexForTableView.xcscheme
│ └── xcschememanagement.plist
├── MJNIndexForTableView
├── CurtainSettings.h
├── CurtainSettings.m
├── Default-568h@2x.png
├── ExamplesSettings.h
├── ExamplesSettings.m
├── FontSettingsView.h
├── FontSettingsView.m
├── Images.xcassets
│ ├── AppIcon.appiconset
│ │ ├── 100.png
│ │ ├── 1024.png
│ │ ├── 114.png
│ │ ├── 120.png
│ │ ├── 144.png
│ │ ├── 152.png
│ │ ├── 167.png
│ │ ├── 180.png
│ │ ├── 20.png
│ │ ├── 29.png
│ │ ├── 40.png
│ │ ├── 50.png
│ │ ├── 57.png
│ │ ├── 58.png
│ │ ├── 60.png
│ │ ├── 72.png
│ │ ├── 76.png
│ │ ├── 80.png
│ │ ├── 87.png
│ │ └── Contents.json
│ ├── Contents.json
│ └── mn splash.imageset
│ │ ├── Contents.json
│ │ ├── mn splash.png
│ │ ├── mn splash@2x.png
│ │ └── mn splash@3x.png
├── LayoutSettingsView.h
├── LayoutSettingsView.m
├── MJNIndexForTableDemoVC.h
├── MJNIndexForTableDemoVC.m
├── MJNIndexForTableView-Info.plist
├── MJNIndexForTableView-Prefix.pch
├── MJNIndexForTableViewAppDelegate.h
├── MJNIndexForTableViewAppDelegate.m
├── MJNIndexView.h
├── MJNIndexView.m
├── closeButton.png
├── closeButton@2x.png
├── crayons.txt
├── crayons2.txt
├── en.lproj
│ └── InfoPlist.strings
├── main.m
├── nextButton.png
├── nextButton@2x.png
├── prevButton.png
├── prevButton@2x.png
├── settingsButton.png
└── settingsButton@2x.png
├── MJNIndexView readMe.rtf
├── MJNIndexView.h
├── MJNIndexView.m
├── MJNIndexView.podspec
├── MJNIndexView01.png
├── MJNIndexView02.png
├── MJNIndexView03.png
├── MJNIndexView04.png
├── README.md
└── _Pods.xcodeproj
/.gitignore:
--------------------------------------------------------------------------------
1 |
2 | MJNIndexForTableView.xcodeproj/project.xcworkspace/xcuserdata/yesjun.xcuserdatad/
3 | MJNIndexForTableView.xcodeproj/xcuserdata/yesjun.xcuserdatad/
4 | MJNIndexForTableView.xcodeproj/project.xcworkspace/xcshareddata/
5 |
--------------------------------------------------------------------------------
/LICENSE.md:
--------------------------------------------------------------------------------
1 | # License
2 |
3 | ## MIT License
4 |
5 | Copyright (c) 2013, Mateusz Nuckowski.
6 | www.mateusz.nuckowski.com
7 | www.appcowboys.com
8 | All rights reserved.
9 |
10 |
11 | Redistribution and use in source and binary forms, with or without
12 | modification, are permitted provided that the following conditions are met:
13 |
14 | 1. Redistributions of the source code must retain the above copyright notice, this
15 | list of conditions and the following disclaimer.
16 |
17 | 2. Redistributions in binary form must reproduce the above copyright notice,
18 | this list of conditions and the following disclaimer in the documentation
19 | and/or other materials provided with the distribution.
20 |
21 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
25 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31 | POSSIBILITY OF SUCH DAMAGE.
--------------------------------------------------------------------------------
/Launch Screen.storyboard:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
--------------------------------------------------------------------------------
/MJNIndexForTableView.xcodeproj/project.pbxproj:
--------------------------------------------------------------------------------
1 | // !$*UTF8*$!
2 | {
3 | archiveVersion = 1;
4 | classes = {
5 | };
6 | objectVersion = 46;
7 | objects = {
8 |
9 | /* Begin PBXBuildFile section */
10 | 0FB6BFAB17F2BC00008D4223 /* CoreText.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0FB6BFAA17F2BC00008D4223 /* CoreText.framework */; };
11 | 402F9A8D1799AAE7001CEB34 /* crayons2.txt in Resources */ = {isa = PBXBuildFile; fileRef = 402F9A8C1799AAE7001CEB34 /* crayons2.txt */; };
12 | 402F9A961799B476001CEB34 /* closeButton.png in Resources */ = {isa = PBXBuildFile; fileRef = 402F9A8E1799B476001CEB34 /* closeButton.png */; };
13 | 402F9A971799B476001CEB34 /* closeButton@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 402F9A8F1799B476001CEB34 /* closeButton@2x.png */; };
14 | 402F9A981799B476001CEB34 /* nextButton.png in Resources */ = {isa = PBXBuildFile; fileRef = 402F9A901799B476001CEB34 /* nextButton.png */; };
15 | 402F9A991799B476001CEB34 /* nextButton@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 402F9A911799B476001CEB34 /* nextButton@2x.png */; };
16 | 402F9A9A1799B476001CEB34 /* prevButton.png in Resources */ = {isa = PBXBuildFile; fileRef = 402F9A921799B476001CEB34 /* prevButton.png */; };
17 | 402F9A9B1799B476001CEB34 /* prevButton@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 402F9A931799B476001CEB34 /* prevButton@2x.png */; };
18 | 402F9A9C1799B476001CEB34 /* settingsButton.png in Resources */ = {isa = PBXBuildFile; fileRef = 402F9A941799B476001CEB34 /* settingsButton.png */; };
19 | 402F9A9D1799B476001CEB34 /* settingsButton@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 402F9A951799B476001CEB34 /* settingsButton@2x.png */; };
20 | 409BDAB6178594B8002E6814 /* crayons.txt in Resources */ = {isa = PBXBuildFile; fileRef = 409BDAB5178594B8002E6814 /* crayons.txt */; };
21 | 409C7C30177C560100BD4EEE /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 409C7C2F177C560100BD4EEE /* UIKit.framework */; };
22 | 409C7C32177C560100BD4EEE /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 409C7C31177C560100BD4EEE /* Foundation.framework */; };
23 | 409C7C34177C560100BD4EEE /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 409C7C33177C560100BD4EEE /* CoreGraphics.framework */; };
24 | 409C7C3A177C560100BD4EEE /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 409C7C38177C560100BD4EEE /* InfoPlist.strings */; };
25 | 409C7C3C177C560100BD4EEE /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 409C7C3B177C560100BD4EEE /* main.m */; };
26 | 409C7C40177C560100BD4EEE /* MJNIndexForTableViewAppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 409C7C3F177C560100BD4EEE /* MJNIndexForTableViewAppDelegate.m */; };
27 | 409C7C57177C593000BD4EEE /* MJNIndexView.m in Sources */ = {isa = PBXBuildFile; fileRef = 409C7C56177C593000BD4EEE /* MJNIndexView.m */; };
28 | 409C7C59177C5EF200BD4EEE /* QuartzCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 409C7C58177C5EF200BD4EEE /* QuartzCore.framework */; };
29 | 40CD6EF723502EBF0093362B /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 40CD6EF623502EBF0093362B /* Images.xcassets */; };
30 | 40CD6EFD235031C00093362B /* Launch Screen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 40CD6EFC235031C00093362B /* Launch Screen.storyboard */; };
31 | 40E1F54217900E7E002DD49F /* MJNIndexForTableDemoVC.m in Sources */ = {isa = PBXBuildFile; fileRef = 40E1F54117900E7E002DD49F /* MJNIndexForTableDemoVC.m */; };
32 | 40FC5438179E91E600EF5B16 /* CurtainSettings.m in Sources */ = {isa = PBXBuildFile; fileRef = 40FC5431179E91E600EF5B16 /* CurtainSettings.m */; };
33 | 40FC5439179E91E600EF5B16 /* ExamplesSettings.m in Sources */ = {isa = PBXBuildFile; fileRef = 40FC5433179E91E600EF5B16 /* ExamplesSettings.m */; };
34 | 40FC543A179E91E600EF5B16 /* FontSettingsView.m in Sources */ = {isa = PBXBuildFile; fileRef = 40FC5435179E91E600EF5B16 /* FontSettingsView.m */; };
35 | 40FC543B179E91E600EF5B16 /* LayoutSettingsView.m in Sources */ = {isa = PBXBuildFile; fileRef = 40FC5437179E91E600EF5B16 /* LayoutSettingsView.m */; };
36 | /* End PBXBuildFile section */
37 |
38 | /* Begin PBXFileReference section */
39 | 0FB6BFAA17F2BC00008D4223 /* CoreText.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreText.framework; path = System/Library/Frameworks/CoreText.framework; sourceTree = SDKROOT; };
40 | 402F9A8C1799AAE7001CEB34 /* crayons2.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = crayons2.txt; sourceTree = ""; };
41 | 402F9A8E1799B476001CEB34 /* closeButton.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = closeButton.png; sourceTree = ""; };
42 | 402F9A8F1799B476001CEB34 /* closeButton@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "closeButton@2x.png"; sourceTree = ""; };
43 | 402F9A901799B476001CEB34 /* nextButton.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = nextButton.png; sourceTree = ""; };
44 | 402F9A911799B476001CEB34 /* nextButton@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "nextButton@2x.png"; sourceTree = ""; };
45 | 402F9A921799B476001CEB34 /* prevButton.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = prevButton.png; sourceTree = ""; };
46 | 402F9A931799B476001CEB34 /* prevButton@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "prevButton@2x.png"; sourceTree = ""; };
47 | 402F9A941799B476001CEB34 /* settingsButton.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = settingsButton.png; sourceTree = ""; };
48 | 402F9A951799B476001CEB34 /* settingsButton@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "settingsButton@2x.png"; sourceTree = ""; };
49 | 409BDAB5178594B8002E6814 /* crayons.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = crayons.txt; sourceTree = ""; };
50 | 409C7C2C177C560100BD4EEE /* MJNIndexForTableView.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = MJNIndexForTableView.app; sourceTree = BUILT_PRODUCTS_DIR; };
51 | 409C7C2F177C560100BD4EEE /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; };
52 | 409C7C31177C560100BD4EEE /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; };
53 | 409C7C33177C560100BD4EEE /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; };
54 | 409C7C37177C560100BD4EEE /* MJNIndexForTableView-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "MJNIndexForTableView-Info.plist"; sourceTree = ""; };
55 | 409C7C39177C560100BD4EEE /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = ""; };
56 | 409C7C3B177C560100BD4EEE /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; };
57 | 409C7C3D177C560100BD4EEE /* MJNIndexForTableView-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "MJNIndexForTableView-Prefix.pch"; sourceTree = ""; };
58 | 409C7C3E177C560100BD4EEE /* MJNIndexForTableViewAppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MJNIndexForTableViewAppDelegate.h; sourceTree = ""; };
59 | 409C7C3F177C560100BD4EEE /* MJNIndexForTableViewAppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MJNIndexForTableViewAppDelegate.m; sourceTree = ""; };
60 | 409C7C55177C593000BD4EEE /* MJNIndexView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MJNIndexView.h; sourceTree = ""; };
61 | 409C7C56177C593000BD4EEE /* MJNIndexView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MJNIndexView.m; sourceTree = ""; };
62 | 409C7C58177C5EF200BD4EEE /* QuartzCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = QuartzCore.framework; path = System/Library/Frameworks/QuartzCore.framework; sourceTree = SDKROOT; };
63 | 40CD6EF623502EBF0093362B /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = ""; };
64 | 40CD6EFC235031C00093362B /* Launch Screen.storyboard */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; path = "Launch Screen.storyboard"; sourceTree = ""; };
65 | 40E1F54017900E7E002DD49F /* MJNIndexForTableDemoVC.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MJNIndexForTableDemoVC.h; sourceTree = ""; };
66 | 40E1F54117900E7E002DD49F /* MJNIndexForTableDemoVC.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MJNIndexForTableDemoVC.m; sourceTree = ""; };
67 | 40FC5430179E91E600EF5B16 /* CurtainSettings.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CurtainSettings.h; sourceTree = ""; };
68 | 40FC5431179E91E600EF5B16 /* CurtainSettings.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CurtainSettings.m; sourceTree = ""; };
69 | 40FC5432179E91E600EF5B16 /* ExamplesSettings.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ExamplesSettings.h; sourceTree = ""; };
70 | 40FC5433179E91E600EF5B16 /* ExamplesSettings.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ExamplesSettings.m; sourceTree = ""; };
71 | 40FC5434179E91E600EF5B16 /* FontSettingsView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FontSettingsView.h; sourceTree = ""; };
72 | 40FC5435179E91E600EF5B16 /* FontSettingsView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FontSettingsView.m; sourceTree = ""; };
73 | 40FC5436179E91E600EF5B16 /* LayoutSettingsView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LayoutSettingsView.h; sourceTree = ""; };
74 | 40FC5437179E91E600EF5B16 /* LayoutSettingsView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LayoutSettingsView.m; sourceTree = ""; };
75 | /* End PBXFileReference section */
76 |
77 | /* Begin PBXFrameworksBuildPhase section */
78 | 409C7C29177C560100BD4EEE /* Frameworks */ = {
79 | isa = PBXFrameworksBuildPhase;
80 | buildActionMask = 2147483647;
81 | files = (
82 | 0FB6BFAB17F2BC00008D4223 /* CoreText.framework in Frameworks */,
83 | 409C7C59177C5EF200BD4EEE /* QuartzCore.framework in Frameworks */,
84 | 409C7C30177C560100BD4EEE /* UIKit.framework in Frameworks */,
85 | 409C7C32177C560100BD4EEE /* Foundation.framework in Frameworks */,
86 | 409C7C34177C560100BD4EEE /* CoreGraphics.framework in Frameworks */,
87 | );
88 | runOnlyForDeploymentPostprocessing = 0;
89 | };
90 | /* End PBXFrameworksBuildPhase section */
91 |
92 | /* Begin PBXGroup section */
93 | 409C7C23177C560100BD4EEE = {
94 | isa = PBXGroup;
95 | children = (
96 | 40CD6EFC235031C00093362B /* Launch Screen.storyboard */,
97 | 409C7C35177C560100BD4EEE /* MJNIndexForTableView */,
98 | 409C7C2E177C560100BD4EEE /* Frameworks */,
99 | 409C7C2D177C560100BD4EEE /* Products */,
100 | );
101 | sourceTree = "";
102 | };
103 | 409C7C2D177C560100BD4EEE /* Products */ = {
104 | isa = PBXGroup;
105 | children = (
106 | 409C7C2C177C560100BD4EEE /* MJNIndexForTableView.app */,
107 | );
108 | name = Products;
109 | sourceTree = "";
110 | };
111 | 409C7C2E177C560100BD4EEE /* Frameworks */ = {
112 | isa = PBXGroup;
113 | children = (
114 | 0FB6BFAA17F2BC00008D4223 /* CoreText.framework */,
115 | 409C7C58177C5EF200BD4EEE /* QuartzCore.framework */,
116 | 409C7C2F177C560100BD4EEE /* UIKit.framework */,
117 | 409C7C31177C560100BD4EEE /* Foundation.framework */,
118 | 409C7C33177C560100BD4EEE /* CoreGraphics.framework */,
119 | );
120 | name = Frameworks;
121 | sourceTree = "";
122 | };
123 | 409C7C35177C560100BD4EEE /* MJNIndexForTableView */ = {
124 | isa = PBXGroup;
125 | children = (
126 | 409C7C3E177C560100BD4EEE /* MJNIndexForTableViewAppDelegate.h */,
127 | 409C7C3F177C560100BD4EEE /* MJNIndexForTableViewAppDelegate.m */,
128 | 40FC5427179E871400EF5B16 /* settings */,
129 | 409C7C55177C593000BD4EEE /* MJNIndexView.h */,
130 | 409C7C56177C593000BD4EEE /* MJNIndexView.m */,
131 | 40E1F54017900E7E002DD49F /* MJNIndexForTableDemoVC.h */,
132 | 40E1F54117900E7E002DD49F /* MJNIndexForTableDemoVC.m */,
133 | 40CD6EF623502EBF0093362B /* Images.xcassets */,
134 | 409C7C36177C560100BD4EEE /* Supporting Files */,
135 | );
136 | path = MJNIndexForTableView;
137 | sourceTree = "";
138 | };
139 | 409C7C36177C560100BD4EEE /* Supporting Files */ = {
140 | isa = PBXGroup;
141 | children = (
142 | 409BDAB5178594B8002E6814 /* crayons.txt */,
143 | 402F9A8C1799AAE7001CEB34 /* crayons2.txt */,
144 | 402F9A8E1799B476001CEB34 /* closeButton.png */,
145 | 402F9A8F1799B476001CEB34 /* closeButton@2x.png */,
146 | 402F9A901799B476001CEB34 /* nextButton.png */,
147 | 402F9A911799B476001CEB34 /* nextButton@2x.png */,
148 | 402F9A921799B476001CEB34 /* prevButton.png */,
149 | 402F9A931799B476001CEB34 /* prevButton@2x.png */,
150 | 402F9A941799B476001CEB34 /* settingsButton.png */,
151 | 402F9A951799B476001CEB34 /* settingsButton@2x.png */,
152 | 409C7C37177C560100BD4EEE /* MJNIndexForTableView-Info.plist */,
153 | 409C7C38177C560100BD4EEE /* InfoPlist.strings */,
154 | 409C7C3B177C560100BD4EEE /* main.m */,
155 | 409C7C3D177C560100BD4EEE /* MJNIndexForTableView-Prefix.pch */,
156 | );
157 | name = "Supporting Files";
158 | sourceTree = "";
159 | };
160 | 40FC5427179E871400EF5B16 /* settings */ = {
161 | isa = PBXGroup;
162 | children = (
163 | 40FC5430179E91E600EF5B16 /* CurtainSettings.h */,
164 | 40FC5431179E91E600EF5B16 /* CurtainSettings.m */,
165 | 40FC5432179E91E600EF5B16 /* ExamplesSettings.h */,
166 | 40FC5433179E91E600EF5B16 /* ExamplesSettings.m */,
167 | 40FC5434179E91E600EF5B16 /* FontSettingsView.h */,
168 | 40FC5435179E91E600EF5B16 /* FontSettingsView.m */,
169 | 40FC5436179E91E600EF5B16 /* LayoutSettingsView.h */,
170 | 40FC5437179E91E600EF5B16 /* LayoutSettingsView.m */,
171 | );
172 | name = settings;
173 | sourceTree = "";
174 | };
175 | /* End PBXGroup section */
176 |
177 | /* Begin PBXNativeTarget section */
178 | 409C7C2B177C560100BD4EEE /* MJNIndexForTableView */ = {
179 | isa = PBXNativeTarget;
180 | buildConfigurationList = 409C7C52177C560100BD4EEE /* Build configuration list for PBXNativeTarget "MJNIndexForTableView" */;
181 | buildPhases = (
182 | 409C7C28177C560100BD4EEE /* Sources */,
183 | 409C7C29177C560100BD4EEE /* Frameworks */,
184 | 409C7C2A177C560100BD4EEE /* Resources */,
185 | );
186 | buildRules = (
187 | );
188 | dependencies = (
189 | );
190 | name = MJNIndexForTableView;
191 | productName = MJNIndexForTableView;
192 | productReference = 409C7C2C177C560100BD4EEE /* MJNIndexForTableView.app */;
193 | productType = "com.apple.product-type.application";
194 | };
195 | /* End PBXNativeTarget section */
196 |
197 | /* Begin PBXProject section */
198 | 409C7C24177C560100BD4EEE /* Project object */ = {
199 | isa = PBXProject;
200 | attributes = {
201 | CLASSPREFIX = MJNIndexForTableView;
202 | LastUpgradeCheck = 1110;
203 | ORGANIZATIONNAME = "Mateusz Nuckowski";
204 | TargetAttributes = {
205 | 409C7C2B177C560100BD4EEE = {
206 | DevelopmentTeam = HH94953BX4;
207 | ProvisioningStyle = Automatic;
208 | };
209 | };
210 | };
211 | buildConfigurationList = 409C7C27177C560100BD4EEE /* Build configuration list for PBXProject "MJNIndexForTableView" */;
212 | compatibilityVersion = "Xcode 3.2";
213 | developmentRegion = en;
214 | hasScannedForEncodings = 0;
215 | knownRegions = (
216 | en,
217 | Base,
218 | );
219 | mainGroup = 409C7C23177C560100BD4EEE;
220 | productRefGroup = 409C7C2D177C560100BD4EEE /* Products */;
221 | projectDirPath = "";
222 | projectRoot = "";
223 | targets = (
224 | 409C7C2B177C560100BD4EEE /* MJNIndexForTableView */,
225 | );
226 | };
227 | /* End PBXProject section */
228 |
229 | /* Begin PBXResourcesBuildPhase section */
230 | 409C7C2A177C560100BD4EEE /* Resources */ = {
231 | isa = PBXResourcesBuildPhase;
232 | buildActionMask = 2147483647;
233 | files = (
234 | 409C7C3A177C560100BD4EEE /* InfoPlist.strings in Resources */,
235 | 40CD6EF723502EBF0093362B /* Images.xcassets in Resources */,
236 | 40CD6EFD235031C00093362B /* Launch Screen.storyboard in Resources */,
237 | 409BDAB6178594B8002E6814 /* crayons.txt in Resources */,
238 | 402F9A8D1799AAE7001CEB34 /* crayons2.txt in Resources */,
239 | 402F9A961799B476001CEB34 /* closeButton.png in Resources */,
240 | 402F9A971799B476001CEB34 /* closeButton@2x.png in Resources */,
241 | 402F9A981799B476001CEB34 /* nextButton.png in Resources */,
242 | 402F9A991799B476001CEB34 /* nextButton@2x.png in Resources */,
243 | 402F9A9A1799B476001CEB34 /* prevButton.png in Resources */,
244 | 402F9A9B1799B476001CEB34 /* prevButton@2x.png in Resources */,
245 | 402F9A9C1799B476001CEB34 /* settingsButton.png in Resources */,
246 | 402F9A9D1799B476001CEB34 /* settingsButton@2x.png in Resources */,
247 | );
248 | runOnlyForDeploymentPostprocessing = 0;
249 | };
250 | /* End PBXResourcesBuildPhase section */
251 |
252 | /* Begin PBXSourcesBuildPhase section */
253 | 409C7C28177C560100BD4EEE /* Sources */ = {
254 | isa = PBXSourcesBuildPhase;
255 | buildActionMask = 2147483647;
256 | files = (
257 | 409C7C3C177C560100BD4EEE /* main.m in Sources */,
258 | 409C7C40177C560100BD4EEE /* MJNIndexForTableViewAppDelegate.m in Sources */,
259 | 409C7C57177C593000BD4EEE /* MJNIndexView.m in Sources */,
260 | 40E1F54217900E7E002DD49F /* MJNIndexForTableDemoVC.m in Sources */,
261 | 40FC5438179E91E600EF5B16 /* CurtainSettings.m in Sources */,
262 | 40FC5439179E91E600EF5B16 /* ExamplesSettings.m in Sources */,
263 | 40FC543A179E91E600EF5B16 /* FontSettingsView.m in Sources */,
264 | 40FC543B179E91E600EF5B16 /* LayoutSettingsView.m in Sources */,
265 | );
266 | runOnlyForDeploymentPostprocessing = 0;
267 | };
268 | /* End PBXSourcesBuildPhase section */
269 |
270 | /* Begin PBXVariantGroup section */
271 | 409C7C38177C560100BD4EEE /* InfoPlist.strings */ = {
272 | isa = PBXVariantGroup;
273 | children = (
274 | 409C7C39177C560100BD4EEE /* en */,
275 | );
276 | name = InfoPlist.strings;
277 | sourceTree = "";
278 | };
279 | /* End PBXVariantGroup section */
280 |
281 | /* Begin XCBuildConfiguration section */
282 | 409C7C50177C560100BD4EEE /* Debug */ = {
283 | isa = XCBuildConfiguration;
284 | buildSettings = {
285 | ALWAYS_SEARCH_USER_PATHS = NO;
286 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
287 | CLANG_CXX_LIBRARY = "libc++";
288 | CLANG_ENABLE_OBJC_ARC = YES;
289 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
290 | CLANG_WARN_BOOL_CONVERSION = YES;
291 | CLANG_WARN_COMMA = YES;
292 | CLANG_WARN_CONSTANT_CONVERSION = YES;
293 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
294 | CLANG_WARN_EMPTY_BODY = YES;
295 | CLANG_WARN_ENUM_CONVERSION = YES;
296 | CLANG_WARN_INFINITE_RECURSION = YES;
297 | CLANG_WARN_INT_CONVERSION = YES;
298 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
299 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
300 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
301 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
302 | CLANG_WARN_STRICT_PROTOTYPES = YES;
303 | CLANG_WARN_SUSPICIOUS_MOVE = YES;
304 | CLANG_WARN_UNREACHABLE_CODE = YES;
305 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
306 | CODE_SIGN_IDENTITY = "iPhone Developer: Mateusz Nuckowski (3XLYJ8RDN7)";
307 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer: Mateusz Nuckowski (3XLYJ8RDN7)";
308 | COPY_PHASE_STRIP = NO;
309 | ENABLE_STRICT_OBJC_MSGSEND = YES;
310 | ENABLE_TESTABILITY = YES;
311 | GCC_C_LANGUAGE_STANDARD = gnu99;
312 | GCC_DYNAMIC_NO_PIC = NO;
313 | GCC_NO_COMMON_BLOCKS = YES;
314 | GCC_OPTIMIZATION_LEVEL = 0;
315 | GCC_PREPROCESSOR_DEFINITIONS = (
316 | "DEBUG=1",
317 | "$(inherited)",
318 | );
319 | GCC_SYMBOLS_PRIVATE_EXTERN = NO;
320 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
321 | GCC_WARN_ABOUT_RETURN_TYPE = YES;
322 | GCC_WARN_UNDECLARED_SELECTOR = YES;
323 | GCC_WARN_UNINITIALIZED_AUTOS = YES;
324 | GCC_WARN_UNUSED_FUNCTION = YES;
325 | GCC_WARN_UNUSED_VARIABLE = YES;
326 | IPHONEOS_DEPLOYMENT_TARGET = 9.1;
327 | ONLY_ACTIVE_ARCH = YES;
328 | PROVISIONING_PROFILE = "30EB8802-E58F-423F-81EE-97D4DC878744";
329 | "PROVISIONING_PROFILE[sdk=iphoneos*]" = "30EB8802-E58F-423F-81EE-97D4DC878744";
330 | SDKROOT = iphoneos;
331 | TARGETED_DEVICE_FAMILY = "1,2";
332 | };
333 | name = Debug;
334 | };
335 | 409C7C51177C560100BD4EEE /* Release */ = {
336 | isa = XCBuildConfiguration;
337 | buildSettings = {
338 | ALWAYS_SEARCH_USER_PATHS = NO;
339 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
340 | CLANG_CXX_LIBRARY = "libc++";
341 | CLANG_ENABLE_OBJC_ARC = YES;
342 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
343 | CLANG_WARN_BOOL_CONVERSION = YES;
344 | CLANG_WARN_COMMA = YES;
345 | CLANG_WARN_CONSTANT_CONVERSION = YES;
346 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
347 | CLANG_WARN_EMPTY_BODY = YES;
348 | CLANG_WARN_ENUM_CONVERSION = YES;
349 | CLANG_WARN_INFINITE_RECURSION = YES;
350 | CLANG_WARN_INT_CONVERSION = YES;
351 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
352 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
353 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
354 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
355 | CLANG_WARN_STRICT_PROTOTYPES = YES;
356 | CLANG_WARN_SUSPICIOUS_MOVE = YES;
357 | CLANG_WARN_UNREACHABLE_CODE = YES;
358 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
359 | CODE_SIGN_IDENTITY = "iPhone Developer: Mateusz Nuckowski (3XLYJ8RDN7)";
360 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer: Mateusz Nuckowski (3XLYJ8RDN7)";
361 | COPY_PHASE_STRIP = YES;
362 | ENABLE_STRICT_OBJC_MSGSEND = YES;
363 | GCC_C_LANGUAGE_STANDARD = gnu99;
364 | GCC_NO_COMMON_BLOCKS = YES;
365 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
366 | GCC_WARN_ABOUT_RETURN_TYPE = YES;
367 | GCC_WARN_UNDECLARED_SELECTOR = YES;
368 | GCC_WARN_UNINITIALIZED_AUTOS = YES;
369 | GCC_WARN_UNUSED_FUNCTION = YES;
370 | GCC_WARN_UNUSED_VARIABLE = YES;
371 | IPHONEOS_DEPLOYMENT_TARGET = 9.1;
372 | OTHER_CFLAGS = "-DNS_BLOCK_ASSERTIONS=1";
373 | PROVISIONING_PROFILE = "30EB8802-E58F-423F-81EE-97D4DC878744";
374 | "PROVISIONING_PROFILE[sdk=iphoneos*]" = "30EB8802-E58F-423F-81EE-97D4DC878744";
375 | SDKROOT = iphoneos;
376 | TARGETED_DEVICE_FAMILY = "1,2";
377 | VALIDATE_PRODUCT = YES;
378 | };
379 | name = Release;
380 | };
381 | 409C7C53177C560100BD4EEE /* Debug */ = {
382 | isa = XCBuildConfiguration;
383 | buildSettings = {
384 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
385 | CODE_SIGN_IDENTITY = "Apple Development";
386 | CODE_SIGN_STYLE = Automatic;
387 | DEVELOPMENT_TEAM = HH94953BX4;
388 | GCC_PRECOMPILE_PREFIX_HEADER = YES;
389 | GCC_PREFIX_HEADER = "MJNIndexForTableView/MJNIndexForTableView-Prefix.pch";
390 | INFOPLIST_FILE = "MJNIndexForTableView/MJNIndexForTableView-Info.plist";
391 | IPHONEOS_DEPLOYMENT_TARGET = 9.1;
392 | PRODUCT_BUNDLE_IDENTIFIER = co.quantumkiwi.MJNINdex;
393 | PRODUCT_NAME = "$(TARGET_NAME)";
394 | PROVISIONING_PROFILE_SPECIFIER = "";
395 | WRAPPER_EXTENSION = app;
396 | };
397 | name = Debug;
398 | };
399 | 409C7C54177C560100BD4EEE /* Release */ = {
400 | isa = XCBuildConfiguration;
401 | buildSettings = {
402 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
403 | CODE_SIGN_IDENTITY = "Apple Distribution";
404 | CODE_SIGN_STYLE = Automatic;
405 | DEVELOPMENT_TEAM = HH94953BX4;
406 | GCC_PRECOMPILE_PREFIX_HEADER = YES;
407 | GCC_PREFIX_HEADER = "MJNIndexForTableView/MJNIndexForTableView-Prefix.pch";
408 | INFOPLIST_FILE = "MJNIndexForTableView/MJNIndexForTableView-Info.plist";
409 | IPHONEOS_DEPLOYMENT_TARGET = 9.1;
410 | PRODUCT_BUNDLE_IDENTIFIER = co.quantumkiwi.MJNINdex;
411 | PRODUCT_NAME = "$(TARGET_NAME)";
412 | PROVISIONING_PROFILE_SPECIFIER = "";
413 | WRAPPER_EXTENSION = app;
414 | };
415 | name = Release;
416 | };
417 | /* End XCBuildConfiguration section */
418 |
419 | /* Begin XCConfigurationList section */
420 | 409C7C27177C560100BD4EEE /* Build configuration list for PBXProject "MJNIndexForTableView" */ = {
421 | isa = XCConfigurationList;
422 | buildConfigurations = (
423 | 409C7C50177C560100BD4EEE /* Debug */,
424 | 409C7C51177C560100BD4EEE /* Release */,
425 | );
426 | defaultConfigurationIsVisible = 0;
427 | defaultConfigurationName = Release;
428 | };
429 | 409C7C52177C560100BD4EEE /* Build configuration list for PBXNativeTarget "MJNIndexForTableView" */ = {
430 | isa = XCConfigurationList;
431 | buildConfigurations = (
432 | 409C7C53177C560100BD4EEE /* Debug */,
433 | 409C7C54177C560100BD4EEE /* Release */,
434 | );
435 | defaultConfigurationIsVisible = 0;
436 | defaultConfigurationName = Release;
437 | };
438 | /* End XCConfigurationList section */
439 | };
440 | rootObject = 409C7C24177C560100BD4EEE /* Project object */;
441 | }
442 |
--------------------------------------------------------------------------------
/MJNIndexForTableView.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/MJNIndexForTableView.xcodeproj/project.xcworkspace/xcuserdata/mat.xcuserdatad/UserInterfaceState (Mateuszs-Mac-mini's conflicted copy 2013-07-12).xcuserstate:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/matthewfx/MJNIndexView/1a46deaec37b09cee7e81856d75171dcdaa3aea6/MJNIndexForTableView.xcodeproj/project.xcworkspace/xcuserdata/mat.xcuserdatad/UserInterfaceState (Mateuszs-Mac-mini's conflicted copy 2013-07-12).xcuserstate
--------------------------------------------------------------------------------
/MJNIndexForTableView.xcodeproj/project.xcworkspace/xcuserdata/mat.xcuserdatad/UserInterfaceState.xcuserstate:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/matthewfx/MJNIndexView/1a46deaec37b09cee7e81856d75171dcdaa3aea6/MJNIndexForTableView.xcodeproj/project.xcworkspace/xcuserdata/mat.xcuserdatad/UserInterfaceState.xcuserstate
--------------------------------------------------------------------------------
/MJNIndexForTableView.xcodeproj/project.xcworkspace/xcuserdata/mat.xcuserdatad/WorkspaceSettings.xcsettings:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | HasAskedToTakeAutomaticSnapshotBeforeSignificantChanges
6 |
7 | SnapshotAutomaticallyBeforeSignificantChanges
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/MJNIndexForTableView.xcodeproj/xcuserdata/mat.xcuserdatad/xcdebugger/Breakpoints.xcbkptlist:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/MJNIndexForTableView.xcodeproj/xcuserdata/mat.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
--------------------------------------------------------------------------------
/MJNIndexForTableView.xcodeproj/xcuserdata/mat.xcuserdatad/xcschemes/MJNIndexForTableView.xcscheme:
--------------------------------------------------------------------------------
1 |
2 |
5 |
8 |
9 |
15 |
21 |
22 |
23 |
24 |
25 |
30 |
31 |
37 |
38 |
39 |
40 |
41 |
42 |
52 |
54 |
60 |
61 |
62 |
63 |
69 |
71 |
77 |
78 |
79 |
80 |
82 |
83 |
86 |
87 |
88 |
--------------------------------------------------------------------------------
/MJNIndexForTableView.xcodeproj/xcuserdata/mat.xcuserdatad/xcschemes/xcschememanagement.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | SchemeUserState
6 |
7 | MJNIndexForTableView.xcscheme
8 |
9 | orderHint
10 | 0
11 |
12 |
13 | SuppressBuildableAutocreation
14 |
15 | 409C7C2B177C560100BD4EEE
16 |
17 | primary
18 |
19 |
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/MJNIndexForTableView/CurtainSettings.h:
--------------------------------------------------------------------------------
1 | //
2 | // CurtainSettings.h
3 | // MJNIndexForTableView
4 | //
5 | // Created by Mateusz Nuckowski on 14/07/13.
6 | // Copyright (c) 2013 Mateusz Nuckowski. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @class CurtainSettings;
12 |
13 | @protocol CurtainSettingsViewDelegate
14 |
15 | - (void)fadeForCurtain: (CGFloat) fade;
16 | - (void)colorForCurtain:(UIColor *)color;
17 | - (void)marginsForCurtain:(BOOL) margins;
18 | - (void)staysForCurtain:(BOOL) stays;
19 | - (void)close;
20 |
21 | @end
22 |
23 | @interface CurtainSettings : UIView
24 |
25 | @property (nonatomic, weak) id delegate;
26 |
27 |
28 |
29 |
30 |
31 | -(id)initWithCurtainColor:(UIColor *)color fade:(CGFloat)fade margins:(BOOL)margins stays:(BOOL)stays;
32 |
33 | @end
34 |
--------------------------------------------------------------------------------
/MJNIndexForTableView/CurtainSettings.m:
--------------------------------------------------------------------------------
1 | //
2 | // CurtainSettings.m
3 | // MJNIndexForTableView
4 | //
5 | // Created by Mateusz Nuckowski on 14/07/13.
6 | // Copyright (c) 2013 Mateusz Nuckowski. All rights reserved.
7 | //
8 |
9 | #import "CurtainSettings.h"
10 |
11 | @interface CurtainSettings ()
12 |
13 | @property (nonatomic, strong) UITextField *curtainFadeValue;
14 | @property (nonatomic, strong) UISlider *curtainFadeSlider;
15 | @property (nonatomic, strong) UILabel *sampleColor;
16 | @property (nonatomic, strong) UITextField *redValue;
17 | @property (nonatomic, strong) UISlider *redValueSlider;
18 | @property (nonatomic, strong) UITextField *greenValue;
19 | @property (nonatomic, strong) UISlider *greenValueSlider;
20 | @property (nonatomic, strong) UITextField *blueValue;
21 | @property (nonatomic, strong) UISlider *blueValueSlider;
22 | @property (nonatomic, strong) UITextField *alphaValue;
23 | @property (nonatomic, strong) UISlider *alphaValueSlider;
24 |
25 | @property (nonatomic, assign)BOOL curtainStays;
26 | @property (nonatomic, assign)BOOL curtainMargins;
27 | @property (nonatomic, assign) CGFloat fade;
28 | @property (nonatomic, strong) UIColor *color;
29 | @property (nonatomic, assign) CGFloat red;
30 | @property (nonatomic, assign) CGFloat green;
31 | @property (nonatomic, assign) CGFloat blue;
32 | @property (nonatomic, assign) CGFloat alphaCh;
33 |
34 | @property (nonatomic, assign) CGFloat prevX;
35 |
36 | @property (nonatomic, strong) NSArray *disabledEnabledControls;
37 |
38 | @end
39 |
40 | @implementation CurtainSettings
41 |
42 | - (id)initWithFrame:(CGRect)frame
43 | {
44 | self = [super initWithFrame:frame];
45 | if (self) {
46 | // Initialization code
47 | }
48 | return self;
49 | }
50 |
51 |
52 | - (id)initWithCurtainColor:(UIColor *)color fade:(CGFloat)fade margins:(BOOL)margins stays:(BOOL)stays
53 | {
54 | if (self = [super initWithFrame:CGRectZero]) {
55 | self.curtainStays = stays;
56 | self.curtainMargins = margins;
57 | self.fade = fade;
58 | self.color = color;
59 |
60 | // Current color values
61 |
62 | if (color) {
63 | const CGFloat *colorComponents = CGColorGetComponents(self.color.CGColor);
64 | self.red = colorComponents[0];
65 | self.green = colorComponents[1];
66 | self.blue = colorComponents[2];
67 | self.alphaCh = colorComponents[3];
68 | } else {
69 | self.red = 1.0;
70 | self.green = 1.0;
71 | self.blue = 1.0;
72 | self.alphaCh = 1.0;
73 | }
74 |
75 | [self drawElements];
76 | }
77 |
78 | return self;
79 | }
80 |
81 |
82 | - (void) drawElements
83 | {
84 | // title label
85 | UILabel *title = [[UILabel alloc]initWithFrame:CGRectMake(20.0, 20.0, 210.0, 21.0)];
86 | title.backgroundColor = [UIColor clearColor];
87 | title.text = @"Curtain settings";
88 | [self addSubview:title];
89 |
90 |
91 | // curtain switches
92 |
93 | // curtain on/off label
94 | UILabel *onOffLabel = [[UILabel alloc]initWithFrame:CGRectMake(20.0, 53.0, 80.0, 21.0)];
95 | onOffLabel.font = [UIFont systemFontOfSize:15];
96 | onOffLabel.backgroundColor = [UIColor clearColor];
97 | onOffLabel.text = @"ON/OFF";
98 | [self addSubview:onOffLabel];
99 |
100 | // on/off switch
101 | UISwitch *onOffSwitch = [[UISwitch alloc]initWithFrame:CGRectMake(141, 50.0, 79.0, 27.0)];
102 | if (!self.color) onOffSwitch.on = NO;
103 | else onOffSwitch.on = YES;
104 | [onOffSwitch addTarget:self action:@selector(onOffChanged:) forControlEvents:UIControlEventValueChanged];
105 | onOffSwitch.tag = 1;
106 | [self addSubview:onOffSwitch];
107 |
108 | // curtainStays label
109 | UILabel *curtainStaysLabel = [[UILabel alloc]initWithFrame:CGRectMake(20.0, 88.0, 100.0, 21.0)];
110 | curtainStaysLabel.font = [UIFont systemFontOfSize:15];
111 | curtainStaysLabel.backgroundColor = [UIColor clearColor];
112 | curtainStaysLabel.text = @"Curtain stays";
113 | [self addSubview:curtainStaysLabel];
114 |
115 | // curtainStays switch
116 | UISwitch *curtainStaysSwitch = [[UISwitch alloc]initWithFrame:CGRectMake(141.0, 85.0, 79.0, 27.0)];
117 | curtainStaysSwitch.on = self.curtainStays;
118 | [curtainStaysSwitch addTarget:self action:@selector(curtainStaysChanged:) forControlEvents:UIControlEventValueChanged];
119 | [self addSubview:curtainStaysSwitch];
120 |
121 | // curtainMargins label
122 | UILabel *curtainMarginsLabel = [[UILabel alloc]initWithFrame:CGRectMake(20.0, 123.0, 110.0, 21.0)];
123 | curtainMarginsLabel.font = [UIFont systemFontOfSize:15.0];
124 | curtainMarginsLabel.backgroundColor = [UIColor clearColor];
125 | curtainMarginsLabel.text = @"Curtain margins";
126 | [self addSubview:curtainMarginsLabel];
127 |
128 | // curtainMargins switch
129 | UISwitch *curtainMarginsSwitch = [[UISwitch alloc]initWithFrame:CGRectMake(141, 120.0, 79.0, 27.0)];
130 | curtainMarginsSwitch.on = self.curtainMargins;
131 | [curtainMarginsSwitch addTarget:self action:@selector(curtainMarginsChanged:) forControlEvents:UIControlEventValueChanged];
132 | [self addSubview:curtainMarginsSwitch];
133 |
134 | // curtain fade label
135 | UILabel *curtainFadeTitle = [[UILabel alloc]initWithFrame:CGRectMake(20.0, 158.0, 100.0, 21.0)];
136 | curtainFadeTitle.font = [UIFont systemFontOfSize: 15.0];
137 | curtainFadeTitle.backgroundColor = [UIColor clearColor];
138 | curtainFadeTitle.text = @"Curtain fade";
139 | [self addSubview:curtainFadeTitle];
140 |
141 | // curtainFadeValue text field
142 | self.curtainFadeValue = [[UITextField alloc]initWithFrame:CGRectMake(150.0, 155.0, 70.0, 25.0)];
143 | self.curtainFadeValue.borderStyle = UITextBorderStyleRoundedRect;
144 | [self.curtainFadeValue setKeyboardType:UIKeyboardTypeNumbersAndPunctuation];
145 | CGFloat currentFade = self.fade;
146 |
147 | [self.curtainFadeValue addTarget:self action:@selector(changeFadeSize:) forControlEvents:UIControlEventEditingChanged];
148 | self.curtainFadeValue.text = [NSString stringWithFormat:@"%.2f",currentFade];
149 |
150 |
151 | [self addSubview:self.curtainFadeValue];
152 |
153 | // curtainFade Slider
154 | self.curtainFadeSlider = [[UISlider alloc]initWithFrame:CGRectMake(20.0, 185.0, 200.0, 23.0)];
155 | self.curtainFadeSlider.minimumValue = 0.0;
156 | self.curtainFadeSlider.maximumValue = 1.0;
157 | self.curtainFadeSlider.value = [self.curtainFadeValue.text floatValue];
158 | [self.curtainFadeSlider addTarget:self action:@selector(curtainFadeSliderChanged:) forControlEvents:UIControlEventValueChanged];
159 | [self addSubview:self.curtainFadeSlider];
160 |
161 | // curtainColor title
162 | UILabel *curtainColorTitle = [[UILabel alloc]initWithFrame:CGRectMake(20.0, 216.0, 100.0, 21.0)];
163 | curtainColorTitle.backgroundColor = [UIColor clearColor];
164 | curtainColorTitle.text = @"Curtain color";
165 | [self addSubview:curtainColorTitle];
166 |
167 | // fontColor sample color
168 | self.sampleColor = [[UILabel alloc]initWithFrame:CGRectMake(20.0, 245.0, 100.0, 27.0)];
169 | if (self.color) self.sampleColor.backgroundColor = self.color;
170 | else self.sampleColor.backgroundColor = [UIColor whiteColor];
171 | [self addSubview:self.sampleColor];
172 |
173 | // R label
174 | UILabel *redLabel = [[UILabel alloc]initWithFrame:CGRectMake(20.0, 280.0, 140.0, 16.0)];
175 | redLabel.font = [UIFont systemFontOfSize: 12.0];
176 | redLabel.text = @"Red";
177 | redLabel.backgroundColor = [UIColor clearColor];
178 | [self addSubview:redLabel];
179 |
180 | // redValue textField
181 | self.redValue = [[UITextField alloc]initWithFrame:CGRectMake(175.0, 295.0, 45.0, 25.0)];
182 | self.redValue.borderStyle = UITextBorderStyleRoundedRect;
183 | [self.redValue setKeyboardType:UIKeyboardTypeNumbersAndPunctuation];
184 | self.redValue.text = [NSString stringWithFormat:@"%d",(int)(self.red * 255.0)];
185 | [self.redValue addTarget:self action:@selector(changeRedValue:) forControlEvents:UIControlEventEditingDidEnd];
186 | [self.redValue addTarget:self action:@selector(moveUp) forControlEvents:UIControlEventEditingDidBegin];
187 | [self addSubview:self.redValue];
188 |
189 | // redValue slider
190 | self.redValueSlider = [[UISlider alloc]initWithFrame:CGRectMake(20.0, 296.0, 145.0, 23.0)];
191 | self.redValueSlider.minimumValue = 0.0;
192 | self.redValueSlider.maximumValue = 255.0;
193 | self.redValueSlider.value = [self.redValue.text floatValue];
194 | [self.redValueSlider addTarget:self action:@selector(redValueSlideChanged:) forControlEvents:UIControlEventValueChanged];
195 | [self addSubview:self.redValueSlider];
196 |
197 | // G label
198 | UILabel *greenLabel = [[UILabel alloc]initWithFrame:CGRectMake(20.0, 320.0, 140.0, 16.0)];
199 | greenLabel.font = [UIFont systemFontOfSize: 12.0];
200 | greenLabel.text = @"Green";
201 | greenLabel.backgroundColor = [UIColor clearColor];
202 | [self addSubview:greenLabel];
203 |
204 | // greenValue textField
205 | self.greenValue = [[UITextField alloc]initWithFrame:CGRectMake(175.0, 335.0, 45.0, 25.0)];
206 | self.greenValue.borderStyle = UITextBorderStyleRoundedRect;
207 | [self.greenValue setKeyboardType:UIKeyboardTypeNumbersAndPunctuation];
208 | self.greenValue.text = [NSString stringWithFormat:@"%d",(int)(self.green * 255.0)];
209 | [self.greenValue addTarget:self action:@selector(changeGreenValue:) forControlEvents:UIControlEventEditingDidEnd];
210 | [self.greenValue addTarget:self action:@selector(moveUp) forControlEvents:UIControlEventEditingDidBegin];
211 |
212 | [self addSubview:self.greenValue];
213 |
214 | // greenValue slider
215 | self.greenValueSlider = [[UISlider alloc]initWithFrame:CGRectMake(20.0, 336.0, 145.0, 23.0)];
216 | self.greenValueSlider.minimumValue = 0.0;
217 | self.greenValueSlider.maximumValue = 255.0;
218 | self.greenValueSlider.value = [self.redValue.text floatValue];
219 | [self.greenValueSlider addTarget:self action:@selector(greenValueSlideChanged:) forControlEvents:UIControlEventValueChanged];
220 | [self addSubview:self.greenValueSlider];
221 |
222 | // B label
223 | UILabel *blueLabel = [[UILabel alloc]initWithFrame:CGRectMake(20.0, 360.0, 140.0, 16.0)];
224 | blueLabel.font = [UIFont systemFontOfSize: 12.0];
225 | blueLabel.text = @"Blue";
226 | blueLabel.backgroundColor = [UIColor clearColor];
227 | [self addSubview:blueLabel];
228 |
229 | // blueValue textField
230 | self.blueValue = [[UITextField alloc]initWithFrame:CGRectMake(175.0, 375.0, 45.0, 25.0)];
231 | self.blueValue.borderStyle = UITextBorderStyleRoundedRect;
232 | [self.blueValue setKeyboardType:UIKeyboardTypeNumbersAndPunctuation];
233 | self.blueValue.text = [NSString stringWithFormat:@"%d",(int)(self.blue * 255.0)];
234 | [self.blueValue addTarget:self action:@selector(changeBlueValue:) forControlEvents:UIControlEventEditingDidEnd];
235 | [self.blueValue addTarget:self action:@selector(moveUp) forControlEvents:UIControlEventEditingDidBegin];
236 |
237 | [self addSubview:self.blueValue];
238 |
239 | // blueValue slider
240 | self.blueValueSlider = [[UISlider alloc]initWithFrame:CGRectMake(20.0, 376.0, 145.0, 23.0)];
241 | self.blueValueSlider.minimumValue = 0.0;
242 | self.blueValueSlider.maximumValue = 255.0;
243 | self.blueValueSlider.value = [self.blueValue.text floatValue];
244 | [self.blueValueSlider addTarget:self action:@selector(blueValueSlideChanged:) forControlEvents:UIControlEventValueChanged];
245 | [self addSubview:self.blueValueSlider];
246 |
247 | // A label
248 | UILabel *alphaLabel = [[UILabel alloc]initWithFrame:CGRectMake(20.0, 400.0, 140.0, 16.0)];
249 | alphaLabel.font = [UIFont systemFontOfSize: 12.0];
250 | alphaLabel.text = @"Alpha";
251 | alphaLabel.backgroundColor = [UIColor clearColor];
252 | [self addSubview:alphaLabel];
253 |
254 | // alphaValue textField
255 | self.alphaValue = [[UITextField alloc]initWithFrame:CGRectMake(175.0, 415.0, 45.0, 25.0)];
256 | self.alphaValue.borderStyle = UITextBorderStyleRoundedRect;
257 | [self.alphaValue setKeyboardType:UIKeyboardTypeNumbersAndPunctuation];
258 | self.alphaValue.text = [NSString stringWithFormat:@"%d",(int)(self.alphaCh * 100.0)];
259 | [self.alphaValue addTarget:self action:@selector(changeAlphaValue:) forControlEvents:UIControlEventEditingDidEnd];
260 | [self addSubview:self.alphaValue];
261 |
262 | // aplphaValue slider
263 | self.alphaValueSlider = [[UISlider alloc]initWithFrame:CGRectMake(20.0, 416.0, 145.0, 23.0)];
264 | self.alphaValueSlider.minimumValue = 0.0;
265 | self.alphaValueSlider.maximumValue = 100.0;
266 | self.alphaValueSlider.value = [self.alphaValue.text floatValue];
267 | [self.alphaValueSlider addTarget:self action:@selector(alphaValueSlideChanged:) forControlEvents:UIControlEventValueChanged];
268 | [self.alphaValue addTarget:self action:@selector(moveUp) forControlEvents:UIControlEventEditingDidBegin];
269 | [self addSubview:self.alphaValueSlider];
270 |
271 | self.disabledEnabledControls = @[self.curtainFadeValue, self.curtainFadeSlider, self.redValue, self.redValueSlider, self.greenValue, self.greenValueSlider, self.blueValue, self.blueValueSlider, self.alphaValue, self.alphaValueSlider];
272 |
273 | if (!self.color) [self enableDisable];
274 |
275 | }
276 |
277 | - (void)changeFadeSize:(UITextField *)sender
278 | {
279 | if ([sender.text floatValue] > self.curtainFadeSlider.maximumValue) sender.text = [NSString stringWithFormat:@"%d",(int)self.curtainFadeSlider.maximumValue];
280 | if ([sender.text floatValue] < self.curtainFadeSlider.minimumValue) sender.text = [NSString stringWithFormat:@"%d",(int)self.curtainFadeSlider.minimumValue];
281 | self.fade = [sender.text floatValue];
282 | [self.delegate fadeForCurtain:self.fade];
283 | self.curtainFadeSlider.value = [sender.text floatValue];
284 | }
285 |
286 | - (void)curtainFadeSliderChanged:(UISlider *)sender
287 | {
288 | self.curtainFadeValue.text = [NSString stringWithFormat:@"%.2f",sender.value];
289 | self.fade = sender.value;
290 | [self.delegate fadeForCurtain:self.fade];
291 | }
292 |
293 | - (void)changeRedValue:(UITextField *)sender
294 | {
295 | if ([sender.text floatValue] > self.redValueSlider.maximumValue) sender.text = [NSString stringWithFormat:@"%d",(int)self.redValueSlider.maximumValue];
296 | if ([sender.text floatValue] < self.redValueSlider.minimumValue) sender.text = [NSString stringWithFormat:@"%d",(int)self.redValueSlider.minimumValue];
297 | self.red = [sender.text floatValue]/255.0;
298 | self.redValueSlider.value = [sender.text floatValue];
299 | [self changeColor];
300 | }
301 |
302 | - (void)redValueSlideChanged:(UISlider *)sender
303 | {
304 | self.red = sender.value/255.0;
305 | self.redValue.text = [NSString stringWithFormat:@"%d",(int)sender.value];
306 | [self changeColor];
307 | }
308 |
309 | - (void)changeGreenValue:(UITextField *)sender
310 | {
311 | if ([sender.text floatValue] > self.greenValueSlider.maximumValue) sender.text = [NSString stringWithFormat:@"%d",(int)self.greenValueSlider.maximumValue];
312 | if ([sender.text floatValue] < self.greenValueSlider.minimumValue) sender.text = [NSString stringWithFormat:@"%d",(int)self.greenValueSlider.minimumValue];
313 | self.green = [sender.text floatValue]/255.0;
314 | self.greenValueSlider.value = [sender.text floatValue];
315 | [self changeColor];
316 | }
317 |
318 | - (void)greenValueSlideChanged:(UISlider *)sender
319 | {
320 | self.green = sender.value/255.0;
321 | self.greenValue.text = [NSString stringWithFormat:@"%d",(int)sender.value];
322 | [self changeColor];
323 | }
324 |
325 |
326 | - (void)changeBlueValue:(UITextField *)sender
327 | {
328 | if ([sender.text floatValue] > self.blueValueSlider.maximumValue) sender.text = [NSString stringWithFormat:@"%d",(int)self.blueValueSlider.maximumValue];
329 | if ([sender.text floatValue] < self.blueValueSlider.minimumValue) sender.text = [NSString stringWithFormat:@"%d",(int)self.blueValueSlider.minimumValue];
330 |
331 | self.blue = [sender.text floatValue]/255.0;
332 | self.blueValueSlider.value = [sender.text floatValue];
333 | [self changeColor];
334 | }
335 |
336 | - (void)blueValueSlideChanged:(UISlider *)sender
337 | {
338 | self.blue = sender.value/255.0;
339 | self.blueValue.text = [NSString stringWithFormat:@"%d",(int)sender.value];
340 | [self changeColor];
341 | }
342 |
343 | - (void)changeAlphaValue:(UITextField *)sender
344 | {
345 | if ([sender.text floatValue] > self.alphaValueSlider.maximumValue) sender.text = [NSString stringWithFormat:@"%d",(int)self.alphaValueSlider.maximumValue];
346 | if ([sender.text floatValue] < self.alphaValueSlider.minimumValue) sender.text = [NSString stringWithFormat:@"%d",(int)self.alphaValueSlider.minimumValue];
347 |
348 | self.alphaCh = [sender.text floatValue]/100.0;
349 | self.alphaValueSlider.value = [sender.text floatValue];
350 | [self changeColor];
351 | }
352 |
353 | - (void)alphaValueSlideChanged:(UISlider *)sender
354 | {
355 | self.alphaCh = sender.value/100.0;
356 | self.alphaValue.text = [NSString stringWithFormat:@"%d",(int)sender.value];
357 | [self changeColor];
358 | }
359 |
360 | - (void)changeColor
361 | {
362 | self.color = [UIColor colorWithRed:self.red green:self.green blue:self.blue alpha:self.alphaCh];
363 | self.sampleColor.backgroundColor = self.color;
364 | [self.delegate colorForCurtain:self.color];
365 | }
366 |
367 |
368 | - (void)onOffChanged:(UISwitch *)sender
369 | {
370 | if (!sender.on) [self.delegate colorForCurtain:nil];
371 | else {
372 | [self changeColor];
373 | [self.delegate colorForCurtain:self.color];
374 | }
375 | [self enableDisable];
376 | }
377 |
378 |
379 | - (void)curtainMarginsChanged:(UISwitch *)sender
380 | {
381 | self.curtainMargins = sender.on;
382 | [self.delegate marginsForCurtain:self.curtainMargins];
383 | }
384 |
385 | - (void)curtainStaysChanged:(UISwitch *)sender
386 | {
387 | self.curtainStays = sender.on;
388 | [self.delegate staysForCurtain:self.curtainStays];
389 | }
390 |
391 |
392 | - (void)enableDisable
393 | {
394 | for (id control in self.disabledEnabledControls) {
395 | if ([control isKindOfClass:[UISlider class]]) {
396 | UISlider *slider = control;
397 | slider.enabled = !slider.enabled;
398 | } else if ([control isKindOfClass:[UITextField class]]) {
399 | UITextField *textField = control;
400 | textField.enabled = !textField.enabled;
401 | }
402 | }
403 |
404 | }
405 |
406 |
407 | #pragma mark moving view up and down
408 | - (void) moveUp
409 | {
410 | if (self.frame.origin.y == 0.0) {
411 | [UIView beginAnimations:@"moveUp" context:NULL];
412 | self.frame = CGRectOffset(self.frame, 0.0, -200.0);
413 | [UIView commitAnimations];
414 | }
415 | }
416 |
417 | - (void) moveDown
418 | {
419 | if (self.frame.origin.y < 0.0) {
420 | [UIView beginAnimations:@"moveDown" context:NULL];
421 | self.frame = CGRectOffset(self.frame, 0.0, 200.0);
422 | [UIView commitAnimations];
423 | }
424 | }
425 |
426 |
427 | #pragma mark methods for keyboard dismissal
428 | - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
429 | {
430 | CGPoint tappedPt = [[touches anyObject] locationInView: self];
431 | self.prevX = tappedPt.x;
432 | for (id subView in self.subviews) {
433 | if ([subView isMemberOfClass:[UITextField class]]) {
434 | UITextField *textField = subView;
435 | [textField resignFirstResponder];
436 | }
437 |
438 | }
439 | [self moveDown];
440 | }
441 |
442 | - (BOOL)textFieldShouldReturn:(UITextField *)textField
443 | {
444 | [textField resignFirstResponder];
445 | [self moveDown];
446 | return YES;
447 | }
448 |
449 | - (void) willMoveToSuperview:(UIView *)newSuperview
450 | {
451 | for (id subView in self.subviews) {
452 | if ([subView isMemberOfClass:[UITextField class]]) {
453 | UITextField *textField = subView;
454 | textField.delegate = self;
455 | }
456 | }
457 |
458 | }
459 |
460 |
461 | // method for swipe to close
462 |
463 | - (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
464 | {
465 | CGPoint tappedPt = [[touches anyObject] locationInView: self];
466 | CGFloat currentX = tappedPt.x;
467 | if (self.prevX - currentX > 20.0) [self.delegate close];
468 | }
469 |
470 | /*
471 | // Only override drawRect: if you perform custom drawing.
472 | // An empty implementation adversely affects performance during animation.
473 | - (void)drawRect:(CGRect)rect
474 | {
475 | // Drawing code
476 | }
477 | */
478 |
479 | @end
480 |
--------------------------------------------------------------------------------
/MJNIndexForTableView/Default-568h@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/matthewfx/MJNIndexView/1a46deaec37b09cee7e81856d75171dcdaa3aea6/MJNIndexForTableView/Default-568h@2x.png
--------------------------------------------------------------------------------
/MJNIndexForTableView/ExamplesSettings.h:
--------------------------------------------------------------------------------
1 | //
2 | // ExamplesSettings.h
3 | // MJNIndexForTableView
4 | //
5 | // Created by Mateusz Nuckowski on 18/07/13.
6 | // Copyright (c) 2013 Mateusz Nuckowski. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @class ExamplesSettings;
12 |
13 | @protocol ExampleSettingsViewDelegate
14 |
15 | - (void)examplesSettingsForDemo:(NSArray *)examples andGettingSelectedAfterPan:(BOOL)after;
16 | - (void)close;
17 |
18 | @end
19 |
20 | @interface ExamplesSettings : UIView
21 |
22 | @property (nonatomic, weak) id delegate;
23 |
24 |
25 | - (id)initWithExamples:(NSArray *)examples andGettingSelectedAfterPan:(BOOL)after;
26 |
27 | @end
28 |
--------------------------------------------------------------------------------
/MJNIndexForTableView/ExamplesSettings.m:
--------------------------------------------------------------------------------
1 | //
2 | // ExamplesSettings.m
3 | // MJNIndexForTableView
4 | //
5 | // Created by Mateusz Nuckowski on 18/07/13.
6 | // Copyright (c) 2013 Mateusz Nuckowski. All rights reserved.
7 | //
8 |
9 | #import "ExamplesSettings.h"
10 |
11 | @interface ExamplesSettings ()
12 |
13 | @property (nonatomic, strong) UISwitch *example1;
14 | @property (nonatomic, strong) UISwitch *example2;
15 | @property (nonatomic, strong) UISwitch *example3;
16 | @property (nonatomic, strong) UISwitch *example4;
17 | @property (nonatomic, strong) UISwitch *example5;
18 |
19 | @property (nonatomic, assign) BOOL after;
20 |
21 | @property(nonatomic, strong) NSMutableArray *allExamples;
22 |
23 | @property (nonatomic, assign) CGFloat prevX;
24 |
25 | @end
26 |
27 | @implementation ExamplesSettings
28 |
29 | - (id)initWithFrame:(CGRect)frame
30 | {
31 | self = [super initWithFrame:frame];
32 | if (self) {
33 | // Initialization code
34 | }
35 | return self;
36 | }
37 |
38 | - (id)initWithExamples:(NSArray *)examples andGettingSelectedAfterPan:(BOOL)after
39 | {
40 | if (self = [super initWithFrame:CGRectZero]) {
41 | self.allExamples = [examples mutableCopy];
42 | self.after = after;
43 | [self drawElements];
44 | }
45 |
46 |
47 |
48 | return self;
49 | }
50 |
51 | - (void) drawElements
52 | {
53 | // title label
54 | UILabel *title = [[UILabel alloc]initWithFrame:CGRectMake(20.0, 20.0, 210.0, 21.0)];
55 | title.backgroundColor = [UIColor clearColor];
56 | title.text = @"Choose example";
57 | [self addSubview:title];
58 |
59 |
60 | // examples switches
61 |
62 | // ex1 label
63 | UILabel *example1Label = [[UILabel alloc]initWithFrame:CGRectMake(20.0, 53.0, 80.0, 21.0)];
64 | example1Label.font = [UIFont systemFontOfSize: 15.0];
65 | example1Label.backgroundColor = [UIColor clearColor];
66 | example1Label.text = @"Example 1";
67 | [self addSubview:example1Label];
68 |
69 | // ex1 switch
70 | self.example1 = [[UISwitch alloc]initWithFrame:CGRectMake(141, 50.0, 79.0, 27.0)];
71 | self.example1.on = [self.allExamples[0] boolValue];
72 | self.example1.tag = 1;
73 | [self.example1 addTarget:self action:@selector(exChange:) forControlEvents:UIControlEventValueChanged];
74 | [self addSubview:self.example1];
75 |
76 | // ex2 label
77 | UILabel *example2Label = [[UILabel alloc]initWithFrame:CGRectMake(20.0, 88.0, 100.0, 21.0)];
78 | example2Label.font = [UIFont systemFontOfSize: 15.0];
79 | example2Label.backgroundColor = [UIColor clearColor];
80 | example2Label.text = @"Example 2";
81 | [self addSubview:example2Label];
82 |
83 | // ex2 switch
84 | self.example2 = [[UISwitch alloc]initWithFrame:CGRectMake(141.0, 85.0, 79.0, 27.0)];
85 | self.example2.on = [self.allExamples[1] boolValue];
86 | self.example2.tag = 2;
87 | [self.example2 addTarget:self action:@selector(exChange:) forControlEvents:UIControlEventValueChanged];
88 | [self addSubview:self.example2];
89 |
90 | // ex3 label
91 | UILabel *example3Label = [[UILabel alloc]initWithFrame:CGRectMake(20.0, 123.0, 110.0, 21.0)];
92 | example3Label.font = [UIFont systemFontOfSize: 15.0];
93 | example3Label.backgroundColor = [UIColor clearColor];
94 | example3Label.text = @"Example 3";
95 | [self addSubview:example3Label];
96 |
97 | // ex3 switch
98 | self.example3 = [[UISwitch alloc]initWithFrame:CGRectMake(141, 120.0, 79.0, 27.0)];
99 | self.example3.on = [self.allExamples[2] boolValue];
100 | self.example3.tag = 3;
101 | [self.example3 addTarget:self action:@selector(exChange:) forControlEvents:UIControlEventValueChanged];
102 | [self addSubview:self.example3];
103 |
104 | // ex4 label
105 | UILabel *example4Label = [[UILabel alloc]initWithFrame:CGRectMake(20.0, 158.0, 110.0, 21.0)];
106 | example4Label.font = [UIFont systemFontOfSize: 15.0];
107 | example4Label.backgroundColor = [UIColor clearColor];
108 | example4Label.text = @"Example 4";
109 | [self addSubview:example4Label];
110 |
111 | // ex4 switch
112 | self.example4 = [[UISwitch alloc]initWithFrame:CGRectMake(141, 155.0, 79.0, 27.0)];
113 | self.example4.on = [self.allExamples[3] boolValue];
114 | self.example4.tag = 4;
115 | [self.example4 addTarget:self action:@selector(exChange:) forControlEvents:UIControlEventValueChanged];
116 | [self addSubview:self.example4];
117 |
118 | // ex5 label
119 | UILabel *example5Label = [[UILabel alloc]initWithFrame:CGRectMake(20.0, 193.0, 110.0, 21.0)];
120 | example5Label.font = [UIFont systemFontOfSize: 15.0];
121 | example5Label.backgroundColor = [UIColor clearColor];
122 | example5Label.text = @"Example 5";
123 | [self addSubview:example5Label];
124 |
125 | // ex5 switch
126 | self.example5 = [[UISwitch alloc]initWithFrame:CGRectMake(141, 190.0, 79.0, 27.0)];
127 | self.example5.on = [self.allExamples[4] boolValue];
128 | self.example5.tag = 5;
129 | [self.example5 addTarget:self action:@selector(exChange:) forControlEvents:UIControlEventValueChanged];
130 | [self addSubview:self.example5];
131 |
132 | // getSelected title label
133 | UILabel *getSelTitleLabel = [[UILabel alloc]initWithFrame:CGRectMake(20.0, 240.0, 100.0, 152.0)];
134 | getSelTitleLabel.font = [UIFont systemFontOfSize:15];
135 | getSelTitleLabel.numberOfLines = 7;
136 | getSelTitleLabel.backgroundColor = [UIColor clearColor];
137 | getSelTitleLabel.text = @"Getting the selected index item after the panning is finished";
138 | [self addSubview: getSelTitleLabel];
139 |
140 |
141 | // getSelected switch
142 | UISwitch *getSel = [[UISwitch alloc]initWithFrame:CGRectMake(141, 300.0, 79.0, 27.0)];
143 | getSel.on = self.after;
144 | [getSel addTarget:self action:@selector(selectedChange:) forControlEvents:UIControlEventValueChanged];
145 | [self addSubview:getSel];
146 |
147 |
148 | }
149 |
150 | - (void)enabledDisabled
151 | {
152 | [self.delegate close];
153 | [self.example1 setOn:[self.allExamples[0] boolValue] animated:YES];
154 | [self.example2 setOn:[self.allExamples[1] boolValue] animated:YES];
155 | [self.example3 setOn:[self.allExamples[2] boolValue] animated:YES];
156 | [self.example4 setOn:[self.allExamples[3] boolValue] animated:YES];
157 | [self.example5 setOn:[self.allExamples[4] boolValue] animated:YES];
158 |
159 | BOOL allOff;
160 | for (NSNumber *ex in self.allExamples) {
161 | allOff = [ex boolValue];
162 | if ([ex boolValue]) break;
163 | }
164 | if (!allOff) {
165 | [self.example1 setOn:YES animated:YES];
166 | self.allExamples[0] = @(1);
167 | }
168 | }
169 |
170 | - (void)exChange:(UISwitch *)sender
171 | {
172 | self.allExamples = [@[@(0),@(0),@(0),@(0),@(0)] mutableCopy];
173 | self.allExamples[sender.tag -1] = @(sender.on);
174 | [self enabledDisabled];
175 | [self.delegate examplesSettingsForDemo:self.allExamples andGettingSelectedAfterPan:self.after];
176 |
177 | }
178 |
179 | - (void)selectedChange:(UISwitch *)sender
180 | {
181 | self.after = sender.on;
182 | [self.delegate examplesSettingsForDemo:self.allExamples andGettingSelectedAfterPan:self.after];
183 |
184 | }
185 |
186 | @end
187 |
--------------------------------------------------------------------------------
/MJNIndexForTableView/FontSettingsView.h:
--------------------------------------------------------------------------------
1 | //
2 | // FontSettingsView.h
3 | // MJNIndexForTableView
4 | //
5 | // Created by Mateusz Nuckowski on 13/07/13.
6 | // Copyright (c) 2013 Mateusz Nuckowski. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 |
12 | @class FontSettingsView;
13 |
14 | @protocol FontSettingsViewDelegate
15 |
16 | - (void)fontForItem:(UIFont *)font;
17 | - (void)fontForSelectedItem:(UIFont *)font;
18 | - (void)colorForFont:(UIColor *)color;
19 | - (void)colorForSelectedFont:(UIColor *)color;
20 | - (void)close;
21 |
22 | @end
23 |
24 |
25 |
26 | @interface FontSettingsView : UIView
27 |
28 | @property (nonatomic, weak) id delegate;
29 |
30 |
31 | -(id)initWithFont:(UIFont *)font fontColor:(UIColor *)color forSelectedItem:(BOOL)selected;
32 |
33 |
34 | @end
35 |
--------------------------------------------------------------------------------
/MJNIndexForTableView/FontSettingsView.m:
--------------------------------------------------------------------------------
1 | //
2 | // FontSettingsView.m
3 | // MJNIndexForTableView
4 | //
5 | // Created by Mateusz Nuckowski on 13/07/13.
6 | // Copyright (c) 2013 Mateusz Nuckowski. All rights reserved.
7 | //
8 |
9 | #import "FontSettingsView.h"
10 |
11 | @interface FontSettingsView ()
12 | @property (nonatomic, strong) UITextField *fontSizeValue;
13 | @property (nonatomic, strong) UISlider *fontSizeSlider;
14 | @property (nonatomic, strong) UILabel *sampleColor;
15 | @property (nonatomic, strong) UITextField *redValue;
16 | @property (nonatomic, strong) UISlider *redValueSlider;
17 | @property (nonatomic, strong) UITextField *greenValue;
18 | @property (nonatomic, strong) UISlider *greenValueSlider;
19 | @property (nonatomic, strong) UITextField *blueValue;
20 | @property (nonatomic, strong) UISlider *blueValueSlider;
21 | @property (nonatomic, strong) UITextField *alphaValue;
22 | @property (nonatomic, strong) UISlider *alphaValueSlider;
23 |
24 | @property (nonatomic, assign)BOOL selected;
25 | @property (nonatomic, strong) UIFont *font;
26 | @property (nonatomic, strong) UIColor *color;
27 | @property (nonatomic, assign) CGFloat red;
28 | @property (nonatomic, assign) CGFloat green;
29 | @property (nonatomic, assign) CGFloat blue;
30 | @property (nonatomic, assign) CGFloat alphaCh;
31 |
32 | @property (nonatomic, assign) CGFloat prevX;
33 |
34 | @end
35 |
36 | @implementation FontSettingsView
37 |
38 | - (id)initWithFrame:(CGRect)frame
39 | {
40 | self = [super initWithFrame:frame];
41 | if (self) {
42 |
43 |
44 |
45 | }
46 | return self;
47 | }
48 |
49 | - (id)initWithFont:(UIFont *)font fontColor:(UIColor *)color forSelectedItem:(BOOL)selected
50 | {
51 | if (self = [super initWithFrame:CGRectZero]) {
52 | self.selected = selected;
53 | self.font = font;
54 | self.color = color;
55 | // Current color values
56 | const CGFloat *colorComponents = CGColorGetComponents(self.color.CGColor);
57 | self.red = colorComponents[0];
58 | self.green = colorComponents[1];
59 | self.blue = colorComponents[2];
60 | self.alphaCh = colorComponents[3];
61 | [self drawElements];
62 | }
63 |
64 | return self;
65 | }
66 |
67 |
68 |
69 | - (void) drawElements
70 | {
71 | // title label
72 | UILabel *title = [[UILabel alloc]initWithFrame:CGRectMake(20.0, 20.0, 210.0, 21.0)];
73 | title.font = [UIFont systemFontOfSize: 15.0];
74 | title.backgroundColor = [UIColor clearColor];
75 | if (self.selected) title.text = @"Selected item font name";
76 | else title.text = @"Items font name";
77 | [self addSubview:title];
78 |
79 |
80 | // font name segmented control
81 | NSArray *fontNames = @[@"Helvetica",@"Times",@"Gill"];
82 | NSArray *fontNamesForItems = @[@"HelveticaNeue",@"TimesNewRomanPSMT",@"GillSans"];
83 | NSArray *fontNamesForSelectedItems = @[@"HelveticaNeue-Bold",@"TimesNewRomanPS-BoldMT",@"GillSans-Bold"];
84 | UISegmentedControl *fontNameSelector = [[UISegmentedControl alloc]initWithItems:fontNames];
85 | UIFont *font = [UIFont boldSystemFontOfSize:10.0];
86 | NSDictionary *attributes = @{NSFontAttributeName:font};
87 | [fontNameSelector setTitleTextAttributes:attributes
88 | forState:UIControlStateNormal];
89 | fontNameSelector.frame = CGRectMake(20.0, 54.0, 200, 40);
90 |
91 | if (!self.selected) {
92 | for (int num = 0 ; num < [fontNamesForItems count]; num++) {
93 | if ([self.font.fontName isEqualToString: fontNamesForItems[num]]) {
94 | fontNameSelector.selectedSegmentIndex = num;
95 | }
96 | }
97 | } else {
98 | for (int num = 0 ; num < [fontNamesForSelectedItems count]; num++) {
99 | if ([self.font.fontName isEqualToString: fontNamesForSelectedItems[num]]) {
100 | fontNameSelector.selectedSegmentIndex = num;
101 | }
102 | }
103 | }
104 | [fontNameSelector addTarget:self action:@selector(changeFontName:) forControlEvents:UIControlEventValueChanged];
105 | [self addSubview:fontNameSelector];
106 |
107 | // fontSize label
108 | UILabel *fontSizeTitle = [[UILabel alloc]initWithFrame:CGRectMake(20.0, 120.0, 70.0, 21.0)];
109 | fontSizeTitle.backgroundColor = [UIColor clearColor];
110 | fontSizeTitle.text = @"Font size";
111 | [self addSubview:fontSizeTitle];
112 |
113 | // fontSize text field
114 | self.fontSizeValue = [[UITextField alloc]initWithFrame:CGRectMake(150.0, 120.0, 70.0, 25.0)];
115 | self.fontSizeValue.borderStyle = UITextBorderStyleRoundedRect;
116 | [self.fontSizeValue setKeyboardType:UIKeyboardTypeNumbersAndPunctuation];
117 |
118 | CGFloat currentFontSize = self.font.pointSize;
119 |
120 | [self.fontSizeValue addTarget:self action:@selector(changeFontSize:) forControlEvents:UIControlEventEditingChanged];
121 | self.fontSizeValue.text = [NSString stringWithFormat:@"%.2f",currentFontSize];
122 |
123 |
124 | [self addSubview:self.fontSizeValue];
125 |
126 | // fontSize slider
127 | self.fontSizeSlider = [[UISlider alloc]initWithFrame:CGRectMake(20.0, 150.0, 200.0, 23.0)];
128 | self.fontSizeSlider.minimumValue = 4.0;
129 | self.fontSizeSlider.maximumValue = 100.0;
130 | self.fontSizeSlider.value = [self.fontSizeValue.text floatValue];
131 | [self.fontSizeSlider addTarget:self action:@selector(fontSizeSliderChanged:) forControlEvents:UIControlEventValueChanged];
132 | [self addSubview:self.fontSizeSlider];
133 |
134 | // fontColor title
135 | UILabel *fontColorTitle = [[UILabel alloc]initWithFrame:CGRectMake(20.0, 185.0, 150.0, 21.0)];
136 | fontColorTitle.backgroundColor = [UIColor clearColor];
137 | fontColorTitle.text = @"Font color";
138 | [self addSubview:fontColorTitle];
139 |
140 | // fontColor sample color
141 | self.sampleColor = [[UILabel alloc]initWithFrame:CGRectMake(20.0, 180.0, 200.0, 100.0)];
142 | self.sampleColor.backgroundColor = [UIColor clearColor];
143 | self.sampleColor.font = [UIFont fontWithName:@"HelveticaNeue-Bold" size:80.0];
144 | self.sampleColor.text = @"a";
145 | self.sampleColor.textColor = self.color;
146 | [self addSubview:self.sampleColor];
147 |
148 |
149 | // R label
150 | UILabel *redLabel = [[UILabel alloc]initWithFrame:CGRectMake(20.0, 280.0, 140.0, 16.0)];
151 | redLabel.font = [UIFont systemFontOfSize: 12.0];
152 | redLabel.text = @"Red";
153 | redLabel.backgroundColor = [UIColor clearColor];
154 | [self addSubview:redLabel];
155 |
156 | // redValue textField
157 | self.redValue = [[UITextField alloc]initWithFrame:CGRectMake(175.0, 295.0, 45.0, 25.0)];
158 | self.redValue.borderStyle = UITextBorderStyleRoundedRect;
159 | [self.redValue setKeyboardType:UIKeyboardTypeNumbersAndPunctuation];
160 | self.redValue.text = [NSString stringWithFormat:@"%d",(int)(self.red * 255.0)];
161 | [self.redValue addTarget:self action:@selector(changeRedValue:) forControlEvents:UIControlEventEditingDidEnd];
162 | [self.redValue addTarget:self action:@selector(moveUp) forControlEvents:UIControlEventEditingDidBegin];
163 | [self addSubview:self.redValue];
164 |
165 | // redValue slider
166 | self.redValueSlider = [[UISlider alloc]initWithFrame:CGRectMake(20.0, 296.0, 145.0, 23.0)];
167 | self.redValueSlider.minimumValue = 0.0;
168 | self.redValueSlider.maximumValue = 255.0;
169 | self.redValueSlider.value = [self.redValue.text floatValue];
170 | [self.redValueSlider addTarget:self action:@selector(redValueSlideChanged:) forControlEvents:UIControlEventValueChanged];
171 | [self addSubview:self.redValueSlider];
172 |
173 | // G label
174 | UILabel *greenLabel = [[UILabel alloc]initWithFrame:CGRectMake(20.0, 320.0, 140.0, 16.0)];
175 | greenLabel.font = [UIFont systemFontOfSize: 12.0];
176 | greenLabel.text = @"Green";
177 | greenLabel.backgroundColor = [UIColor clearColor];
178 | [self addSubview:greenLabel];
179 |
180 | // greenValue textField
181 | self.greenValue = [[UITextField alloc]initWithFrame:CGRectMake(175.0, 335.0, 45.0, 25.0)];
182 | self.greenValue.borderStyle = UITextBorderStyleRoundedRect;
183 | [self.greenValue setKeyboardType:UIKeyboardTypeNumbersAndPunctuation];
184 | self.greenValue.text = [NSString stringWithFormat:@"%d",(int)(self.green * 255.0)];
185 | [self.greenValue addTarget:self action:@selector(changeGreenValue:) forControlEvents:UIControlEventEditingDidEnd];
186 | [self.greenValue addTarget:self action:@selector(moveUp) forControlEvents:UIControlEventEditingDidBegin];
187 |
188 | [self addSubview:self.greenValue];
189 |
190 | // greenValue slider
191 | self.greenValueSlider = [[UISlider alloc]initWithFrame:CGRectMake(20.0, 336.0, 145.0, 23.0)];
192 | self.greenValueSlider.minimumValue = 0.0;
193 | self.greenValueSlider.maximumValue = 255.0;
194 | self.greenValueSlider.value = [self.redValue.text floatValue];
195 | [self.greenValueSlider addTarget:self action:@selector(greenValueSlideChanged:) forControlEvents:UIControlEventValueChanged];
196 | [self addSubview:self.greenValueSlider];
197 |
198 | // B label
199 | UILabel *blueLabel = [[UILabel alloc]initWithFrame:CGRectMake(20.0, 360.0, 140.0, 16.0)];
200 | blueLabel.font = [UIFont systemFontOfSize: 12.0];
201 | blueLabel.text = @"Blue";
202 | blueLabel.backgroundColor = [UIColor clearColor];
203 | [self addSubview:blueLabel];
204 |
205 | // blueValue textField
206 | self.blueValue = [[UITextField alloc]initWithFrame:CGRectMake(175.0, 375.0, 45.0, 25.0)];
207 | self.blueValue.borderStyle = UITextBorderStyleRoundedRect;
208 | [self.blueValue setKeyboardType:UIKeyboardTypeNumbersAndPunctuation];
209 | self.blueValue.text = [NSString stringWithFormat:@"%d",(int)(self.blue * 255.0)];
210 | [self.blueValue addTarget:self action:@selector(changeBlueValue:) forControlEvents:UIControlEventEditingDidEnd];
211 | [self.blueValue addTarget:self action:@selector(moveUp) forControlEvents:UIControlEventEditingDidBegin];
212 |
213 | [self addSubview:self.blueValue];
214 |
215 | // blueValue slider
216 | self.blueValueSlider = [[UISlider alloc]initWithFrame:CGRectMake(20.0, 376.0, 145.0, 23.0)];
217 | self.blueValueSlider.minimumValue = 0.0;
218 | self.blueValueSlider.maximumValue = 255.0;
219 | self.blueValueSlider.value = [self.blueValue.text floatValue];
220 | [self.blueValueSlider addTarget:self action:@selector(blueValueSlideChanged:) forControlEvents:UIControlEventValueChanged];
221 | [self addSubview:self.blueValueSlider];
222 |
223 | // A label
224 | UILabel *alphaLabel = [[UILabel alloc]initWithFrame:CGRectMake(20.0, 400.0, 140.0, 16.0)];
225 | alphaLabel.font = [UIFont systemFontOfSize: 12.0];
226 | alphaLabel.text = @"Alpha";
227 | alphaLabel.backgroundColor = [UIColor clearColor];
228 | [self addSubview:alphaLabel];
229 |
230 | // alphaValue textField
231 | self.alphaValue = [[UITextField alloc]initWithFrame:CGRectMake(175.0, 415.0, 45.0, 25.0)];
232 | self.alphaValue.borderStyle = UITextBorderStyleRoundedRect;
233 | [self.alphaValue setKeyboardType:UIKeyboardTypeNumbersAndPunctuation];
234 | self.alphaValue.text = [NSString stringWithFormat:@"%d",(int)(self.alphaCh * 100.0)];
235 | [self.alphaValue addTarget:self action:@selector(changeAlphaValue:) forControlEvents:UIControlEventEditingDidEnd];
236 | [self addSubview:self.alphaValue];
237 |
238 | // aplphaValue slider
239 | self.alphaValueSlider = [[UISlider alloc]initWithFrame:CGRectMake(20.0, 416.0, 145.0, 23.0)];
240 | self.alphaValueSlider.minimumValue = 0.0;
241 | self.alphaValueSlider.maximumValue = 100.0;
242 | self.alphaValueSlider.value = [self.alphaValue.text floatValue];
243 | [self.alphaValueSlider addTarget:self action:@selector(alphaValueSlideChanged:) forControlEvents:UIControlEventValueChanged];
244 | [self.alphaValue addTarget:self action:@selector(moveUp) forControlEvents:UIControlEventEditingDidBegin];
245 | [self addSubview:self.alphaValueSlider];
246 |
247 |
248 |
249 | }
250 |
251 | - (void)changeFontName:(UISegmentedControl *)sender
252 | {
253 | NSArray *fontNamesForItems = @[@"HelveticaNeue",@"TimesNewRomanPSMT",@"GillSans"];
254 | NSArray *fontNamesForSelectedItems = @[@"HelveticaNeue-Bold",@"TimesNewRomanPS-BoldMT",@"GillSans-Bold"];
255 |
256 |
257 | if (!self.selected) {
258 | self.font = [UIFont fontWithName:fontNamesForItems[sender.selectedSegmentIndex] size:self.font.pointSize];
259 | [self.delegate fontForItem:self.font];
260 | }else {
261 | self.font = [UIFont fontWithName:fontNamesForSelectedItems[sender.selectedSegmentIndex] size:self.font.pointSize];
262 | [self.delegate fontForSelectedItem:self.font];
263 | }
264 | }
265 |
266 | - (void)changeFontSize:(UITextField *)sender
267 | {
268 | if ([sender.text floatValue] > self.fontSizeSlider.maximumValue) sender.text = [NSString stringWithFormat:@"%.2f",self.fontSizeSlider.maximumValue];
269 | if ([sender.text floatValue] < self.fontSizeSlider.minimumValue) sender.text = [NSString stringWithFormat:@"%.2f",self.fontSizeSlider.minimumValue];
270 | if (!self.selected) {
271 | self.font = [UIFont fontWithName:self.font.fontName size:[sender.text floatValue]];
272 | [self.delegate fontForItem:self.font];
273 | }else {
274 | self.font = [UIFont fontWithName:self.font.fontName size:[sender.text floatValue]];
275 | [self.delegate fontForSelectedItem:self.font];
276 | }
277 |
278 | self.fontSizeSlider.value = [sender.text floatValue];
279 | }
280 |
281 | - (void)fontSizeSliderChanged:(UISlider *)sender
282 | {
283 | self.fontSizeValue.text = [NSString stringWithFormat:@"%.2f",sender.value];
284 | if (!self.selected) {
285 | self.font = [UIFont fontWithName:self.font.fontName size:sender.value];
286 | [self.delegate fontForItem:self.font];
287 | }else {
288 | self.font = [UIFont fontWithName:self.font.fontName size:sender.value];
289 | [self.delegate fontForSelectedItem:self.font];
290 | }
291 |
292 | }
293 |
294 | - (void)changeRedValue:(UITextField *)sender
295 | {
296 | if ([sender.text floatValue] > self.redValueSlider.maximumValue) sender.text = [NSString stringWithFormat:@"%d",(int)self.redValueSlider.maximumValue];
297 | if ([sender.text floatValue] < self.redValueSlider.minimumValue) sender.text = [NSString stringWithFormat:@"%d",(int)self.redValueSlider.minimumValue];
298 | self.red = [sender.text floatValue]/255.0;
299 | self.redValueSlider.value = [sender.text floatValue];
300 | [self changeColor];
301 | }
302 |
303 | - (void)redValueSlideChanged:(UISlider *)sender
304 | {
305 | self.red = sender.value/255.0;
306 | self.redValue.text = [NSString stringWithFormat:@"%d",(int)sender.value];
307 | [self changeColor];
308 | }
309 |
310 | - (void)changeGreenValue:(UITextField *)sender
311 | {
312 | if ([sender.text floatValue] > self.greenValueSlider.maximumValue) sender.text = [NSString stringWithFormat:@"%d",(int)self.greenValueSlider.maximumValue];
313 | if ([sender.text floatValue] < self.greenValueSlider.minimumValue) sender.text = [NSString stringWithFormat:@"%d",(int)self.greenValueSlider.minimumValue];
314 | self.green = [sender.text floatValue]/255.0;
315 | self.greenValueSlider.value = [sender.text floatValue];
316 | [self changeColor];
317 | }
318 |
319 | - (void)greenValueSlideChanged:(UISlider *)sender
320 | {
321 | self.green = sender.value/255.0;
322 | self.greenValue.text = [NSString stringWithFormat:@"%d",(int)sender.value];
323 | [self changeColor];
324 | }
325 |
326 |
327 | - (void)changeBlueValue:(UITextField *)sender
328 | {
329 | if ([sender.text floatValue] > self.blueValueSlider.maximumValue) sender.text = [NSString stringWithFormat:@"%d",(int)self.blueValueSlider.maximumValue];
330 | if ([sender.text floatValue] < self.blueValueSlider.minimumValue) sender.text = [NSString stringWithFormat:@"%d",(int)self.blueValueSlider.minimumValue];
331 |
332 | self.blue = [sender.text floatValue]/255.0;
333 | self.blueValueSlider.value = [sender.text floatValue];
334 | [self changeColor];
335 | }
336 |
337 | - (void)blueValueSlideChanged:(UISlider *)sender
338 | {
339 | self.blue = sender.value/255.0;
340 | self.blueValue.text = [NSString stringWithFormat:@"%d",(int)sender.value];
341 | [self changeColor];
342 | }
343 |
344 | - (void)changeAlphaValue:(UITextField *)sender
345 | {
346 | if ([sender.text floatValue] > self.alphaValueSlider.maximumValue) sender.text = [NSString stringWithFormat:@"%d",(int)self.alphaValueSlider.maximumValue];
347 | if ([sender.text floatValue] < self.alphaValueSlider.minimumValue) sender.text = [NSString stringWithFormat:@"%d",(int)self.alphaValueSlider.minimumValue];
348 |
349 | self.alphaCh = [sender.text floatValue]/100.0;
350 | self.alphaValueSlider.value = [sender.text floatValue];
351 | [self changeColor];
352 | }
353 |
354 | - (void)alphaValueSlideChanged:(UISlider *)sender
355 | {
356 | self.alphaCh = sender.value/100.0;
357 | self.alphaValue.text = [NSString stringWithFormat:@"%d",(int)sender.value];
358 | [self changeColor];
359 | }
360 |
361 | - (void)changeColor
362 | {
363 | self.color = [UIColor colorWithRed:self.red green:self.green blue:self.blue alpha:self.alphaCh];
364 | if (!self.selected) [self.delegate colorForFont:self.color];
365 | else [self.delegate colorForSelectedFont:self.color];
366 | self.sampleColor.textColor = self.color;
367 |
368 | }
369 |
370 | #pragma mark moving view up and down
371 | - (void) moveUp
372 | {
373 | if (self.frame.origin.y == 0.0) {
374 | [UIView beginAnimations:@"moveUp" context:NULL];
375 | self.frame = CGRectOffset(self.frame, 0.0, -200.0);
376 | [UIView commitAnimations];
377 | }
378 | }
379 |
380 | - (void) moveDown
381 | {
382 | if (self.frame.origin.y < 0.0) {
383 | [UIView beginAnimations:@"moveDown" context:NULL];
384 | self.frame = CGRectOffset(self.frame, 0.0, 200.0);
385 | [UIView commitAnimations];
386 | }
387 | }
388 |
389 |
390 | #pragma mark methods for keyboard dismissal
391 | - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
392 | {
393 | CGPoint tappedPt = [[touches anyObject] locationInView: self];
394 | self.prevX = tappedPt.x;
395 | for (id subView in self.subviews) {
396 | if ([subView isMemberOfClass:[UITextField class]]) {
397 | UITextField *textField = subView;
398 | [textField resignFirstResponder];
399 | }
400 |
401 | }
402 | [self moveDown];
403 | }
404 |
405 | - (BOOL)textFieldShouldReturn:(UITextField *)textField
406 | {
407 | [textField resignFirstResponder];
408 | [self moveDown];
409 | return YES;
410 | }
411 |
412 | - (void) willMoveToSuperview:(UIView *)newSuperview
413 | {
414 | for (id subView in self.subviews) {
415 | if ([subView isMemberOfClass:[UITextField class]]) {
416 | UITextField *textField = subView;
417 | textField.delegate = self;
418 | }
419 | }
420 |
421 | }
422 |
423 |
424 | // method for swipe to close
425 |
426 | - (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
427 | {
428 | CGPoint tappedPt = [[touches anyObject] locationInView: self];
429 | CGFloat currentX = tappedPt.x;
430 | if (self.prevX - currentX > 20.0) [self.delegate close];
431 | }
432 |
433 | /*
434 | // Only override drawRect: if you perform custom drawing.
435 | // An empty implementation adversely affects performance during animation.
436 | - (void)drawRect:(CGRect)rect
437 | {
438 | // Drawing code
439 | }
440 | */
441 |
442 | @end
443 |
--------------------------------------------------------------------------------
/MJNIndexForTableView/Images.xcassets/AppIcon.appiconset/100.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/matthewfx/MJNIndexView/1a46deaec37b09cee7e81856d75171dcdaa3aea6/MJNIndexForTableView/Images.xcassets/AppIcon.appiconset/100.png
--------------------------------------------------------------------------------
/MJNIndexForTableView/Images.xcassets/AppIcon.appiconset/1024.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/matthewfx/MJNIndexView/1a46deaec37b09cee7e81856d75171dcdaa3aea6/MJNIndexForTableView/Images.xcassets/AppIcon.appiconset/1024.png
--------------------------------------------------------------------------------
/MJNIndexForTableView/Images.xcassets/AppIcon.appiconset/114.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/matthewfx/MJNIndexView/1a46deaec37b09cee7e81856d75171dcdaa3aea6/MJNIndexForTableView/Images.xcassets/AppIcon.appiconset/114.png
--------------------------------------------------------------------------------
/MJNIndexForTableView/Images.xcassets/AppIcon.appiconset/120.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/matthewfx/MJNIndexView/1a46deaec37b09cee7e81856d75171dcdaa3aea6/MJNIndexForTableView/Images.xcassets/AppIcon.appiconset/120.png
--------------------------------------------------------------------------------
/MJNIndexForTableView/Images.xcassets/AppIcon.appiconset/144.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/matthewfx/MJNIndexView/1a46deaec37b09cee7e81856d75171dcdaa3aea6/MJNIndexForTableView/Images.xcassets/AppIcon.appiconset/144.png
--------------------------------------------------------------------------------
/MJNIndexForTableView/Images.xcassets/AppIcon.appiconset/152.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/matthewfx/MJNIndexView/1a46deaec37b09cee7e81856d75171dcdaa3aea6/MJNIndexForTableView/Images.xcassets/AppIcon.appiconset/152.png
--------------------------------------------------------------------------------
/MJNIndexForTableView/Images.xcassets/AppIcon.appiconset/167.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/matthewfx/MJNIndexView/1a46deaec37b09cee7e81856d75171dcdaa3aea6/MJNIndexForTableView/Images.xcassets/AppIcon.appiconset/167.png
--------------------------------------------------------------------------------
/MJNIndexForTableView/Images.xcassets/AppIcon.appiconset/180.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/matthewfx/MJNIndexView/1a46deaec37b09cee7e81856d75171dcdaa3aea6/MJNIndexForTableView/Images.xcassets/AppIcon.appiconset/180.png
--------------------------------------------------------------------------------
/MJNIndexForTableView/Images.xcassets/AppIcon.appiconset/20.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/matthewfx/MJNIndexView/1a46deaec37b09cee7e81856d75171dcdaa3aea6/MJNIndexForTableView/Images.xcassets/AppIcon.appiconset/20.png
--------------------------------------------------------------------------------
/MJNIndexForTableView/Images.xcassets/AppIcon.appiconset/29.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/matthewfx/MJNIndexView/1a46deaec37b09cee7e81856d75171dcdaa3aea6/MJNIndexForTableView/Images.xcassets/AppIcon.appiconset/29.png
--------------------------------------------------------------------------------
/MJNIndexForTableView/Images.xcassets/AppIcon.appiconset/40.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/matthewfx/MJNIndexView/1a46deaec37b09cee7e81856d75171dcdaa3aea6/MJNIndexForTableView/Images.xcassets/AppIcon.appiconset/40.png
--------------------------------------------------------------------------------
/MJNIndexForTableView/Images.xcassets/AppIcon.appiconset/50.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/matthewfx/MJNIndexView/1a46deaec37b09cee7e81856d75171dcdaa3aea6/MJNIndexForTableView/Images.xcassets/AppIcon.appiconset/50.png
--------------------------------------------------------------------------------
/MJNIndexForTableView/Images.xcassets/AppIcon.appiconset/57.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/matthewfx/MJNIndexView/1a46deaec37b09cee7e81856d75171dcdaa3aea6/MJNIndexForTableView/Images.xcassets/AppIcon.appiconset/57.png
--------------------------------------------------------------------------------
/MJNIndexForTableView/Images.xcassets/AppIcon.appiconset/58.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/matthewfx/MJNIndexView/1a46deaec37b09cee7e81856d75171dcdaa3aea6/MJNIndexForTableView/Images.xcassets/AppIcon.appiconset/58.png
--------------------------------------------------------------------------------
/MJNIndexForTableView/Images.xcassets/AppIcon.appiconset/60.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/matthewfx/MJNIndexView/1a46deaec37b09cee7e81856d75171dcdaa3aea6/MJNIndexForTableView/Images.xcassets/AppIcon.appiconset/60.png
--------------------------------------------------------------------------------
/MJNIndexForTableView/Images.xcassets/AppIcon.appiconset/72.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/matthewfx/MJNIndexView/1a46deaec37b09cee7e81856d75171dcdaa3aea6/MJNIndexForTableView/Images.xcassets/AppIcon.appiconset/72.png
--------------------------------------------------------------------------------
/MJNIndexForTableView/Images.xcassets/AppIcon.appiconset/76.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/matthewfx/MJNIndexView/1a46deaec37b09cee7e81856d75171dcdaa3aea6/MJNIndexForTableView/Images.xcassets/AppIcon.appiconset/76.png
--------------------------------------------------------------------------------
/MJNIndexForTableView/Images.xcassets/AppIcon.appiconset/80.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/matthewfx/MJNIndexView/1a46deaec37b09cee7e81856d75171dcdaa3aea6/MJNIndexForTableView/Images.xcassets/AppIcon.appiconset/80.png
--------------------------------------------------------------------------------
/MJNIndexForTableView/Images.xcassets/AppIcon.appiconset/87.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/matthewfx/MJNIndexView/1a46deaec37b09cee7e81856d75171dcdaa3aea6/MJNIndexForTableView/Images.xcassets/AppIcon.appiconset/87.png
--------------------------------------------------------------------------------
/MJNIndexForTableView/Images.xcassets/AppIcon.appiconset/Contents.json:
--------------------------------------------------------------------------------
1 | {"images":[{"size":"60x60","expected-size":"180","filename":"180.png","folder":"Assets.xcassets/AppIcon.appiconset/","idiom":"iphone","scale":"3x"},{"size":"40x40","expected-size":"80","filename":"80.png","folder":"Assets.xcassets/AppIcon.appiconset/","idiom":"iphone","scale":"2x"},{"size":"40x40","expected-size":"120","filename":"120.png","folder":"Assets.xcassets/AppIcon.appiconset/","idiom":"iphone","scale":"3x"},{"size":"60x60","expected-size":"120","filename":"120.png","folder":"Assets.xcassets/AppIcon.appiconset/","idiom":"iphone","scale":"2x"},{"size":"57x57","expected-size":"57","filename":"57.png","folder":"Assets.xcassets/AppIcon.appiconset/","idiom":"iphone","scale":"1x"},{"size":"29x29","expected-size":"58","filename":"58.png","folder":"Assets.xcassets/AppIcon.appiconset/","idiom":"iphone","scale":"2x"},{"size":"29x29","expected-size":"29","filename":"29.png","folder":"Assets.xcassets/AppIcon.appiconset/","idiom":"iphone","scale":"1x"},{"size":"29x29","expected-size":"87","filename":"87.png","folder":"Assets.xcassets/AppIcon.appiconset/","idiom":"iphone","scale":"3x"},{"size":"57x57","expected-size":"114","filename":"114.png","folder":"Assets.xcassets/AppIcon.appiconset/","idiom":"iphone","scale":"2x"},{"size":"20x20","expected-size":"40","filename":"40.png","folder":"Assets.xcassets/AppIcon.appiconset/","idiom":"iphone","scale":"2x"},{"size":"20x20","expected-size":"60","filename":"60.png","folder":"Assets.xcassets/AppIcon.appiconset/","idiom":"iphone","scale":"3x"},{"size":"1024x1024","filename":"1024.png","expected-size":"1024","idiom":"ios-marketing","folder":"Assets.xcassets/AppIcon.appiconset/","scale":"1x"},{"size":"40x40","expected-size":"80","filename":"80.png","folder":"Assets.xcassets/AppIcon.appiconset/","idiom":"ipad","scale":"2x"},{"size":"72x72","expected-size":"72","filename":"72.png","folder":"Assets.xcassets/AppIcon.appiconset/","idiom":"ipad","scale":"1x"},{"size":"76x76","expected-size":"152","filename":"152.png","folder":"Assets.xcassets/AppIcon.appiconset/","idiom":"ipad","scale":"2x"},{"size":"50x50","expected-size":"100","filename":"100.png","folder":"Assets.xcassets/AppIcon.appiconset/","idiom":"ipad","scale":"2x"},{"size":"29x29","expected-size":"58","filename":"58.png","folder":"Assets.xcassets/AppIcon.appiconset/","idiom":"ipad","scale":"2x"},{"size":"76x76","expected-size":"76","filename":"76.png","folder":"Assets.xcassets/AppIcon.appiconset/","idiom":"ipad","scale":"1x"},{"size":"29x29","expected-size":"29","filename":"29.png","folder":"Assets.xcassets/AppIcon.appiconset/","idiom":"ipad","scale":"1x"},{"size":"50x50","expected-size":"50","filename":"50.png","folder":"Assets.xcassets/AppIcon.appiconset/","idiom":"ipad","scale":"1x"},{"size":"72x72","expected-size":"144","filename":"144.png","folder":"Assets.xcassets/AppIcon.appiconset/","idiom":"ipad","scale":"2x"},{"size":"40x40","expected-size":"40","filename":"40.png","folder":"Assets.xcassets/AppIcon.appiconset/","idiom":"ipad","scale":"1x"},{"size":"83.5x83.5","expected-size":"167","filename":"167.png","folder":"Assets.xcassets/AppIcon.appiconset/","idiom":"ipad","scale":"2x"},{"size":"20x20","expected-size":"20","filename":"20.png","folder":"Assets.xcassets/AppIcon.appiconset/","idiom":"ipad","scale":"1x"},{"size":"20x20","expected-size":"40","filename":"40.png","folder":"Assets.xcassets/AppIcon.appiconset/","idiom":"ipad","scale":"2x"}]}
--------------------------------------------------------------------------------
/MJNIndexForTableView/Images.xcassets/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "info" : {
3 | "version" : 1,
4 | "author" : "xcode"
5 | }
6 | }
--------------------------------------------------------------------------------
/MJNIndexForTableView/Images.xcassets/mn splash.imageset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "universal",
5 | "filename" : "mn splash.png",
6 | "scale" : "1x"
7 | },
8 | {
9 | "idiom" : "universal",
10 | "filename" : "mn splash@2x.png",
11 | "scale" : "2x"
12 | },
13 | {
14 | "idiom" : "universal",
15 | "filename" : "mn splash@3x.png",
16 | "scale" : "3x"
17 | }
18 | ],
19 | "info" : {
20 | "version" : 1,
21 | "author" : "xcode"
22 | }
23 | }
--------------------------------------------------------------------------------
/MJNIndexForTableView/Images.xcassets/mn splash.imageset/mn splash.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/matthewfx/MJNIndexView/1a46deaec37b09cee7e81856d75171dcdaa3aea6/MJNIndexForTableView/Images.xcassets/mn splash.imageset/mn splash.png
--------------------------------------------------------------------------------
/MJNIndexForTableView/Images.xcassets/mn splash.imageset/mn splash@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/matthewfx/MJNIndexView/1a46deaec37b09cee7e81856d75171dcdaa3aea6/MJNIndexForTableView/Images.xcassets/mn splash.imageset/mn splash@2x.png
--------------------------------------------------------------------------------
/MJNIndexForTableView/Images.xcassets/mn splash.imageset/mn splash@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/matthewfx/MJNIndexView/1a46deaec37b09cee7e81856d75171dcdaa3aea6/MJNIndexForTableView/Images.xcassets/mn splash.imageset/mn splash@3x.png
--------------------------------------------------------------------------------
/MJNIndexForTableView/LayoutSettingsView.h:
--------------------------------------------------------------------------------
1 | //
2 | // LayoutSettingsView.h
3 | // MJNIndexForTableView
4 | //
5 | // Created by Mateusz Nuckowski on 14/07/13.
6 | // Copyright (c) 2013 Mateusz Nuckowski. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @class LayoutSettingsView;
12 |
13 | @protocol LayoutSettingsViewDelegate
14 |
15 | - (void)layoutSettingForIndexItems:(NSDictionary *)settings;
16 | - (void)close;
17 |
18 | @end
19 |
20 | @interface LayoutSettingsView : UIView
21 |
22 | @property (nonatomic, weak) id delegate;
23 |
24 | -(id)initWithDeflectionRange:(int)range
25 | maxDeflection:(CGFloat)maxDef
26 | itemAligment:(NSTextAlignment)aligment
27 | rightMargin:(CGFloat)rightM
28 | upperMargin:(CGFloat)upperM
29 | lowerMargin:(CGFloat)lowerM
30 | darkening:(BOOL)darkening
31 | fading:(BOOL)fading
32 | ergoHeight:(BOOL)ergo;
33 |
34 | @end
35 |
--------------------------------------------------------------------------------
/MJNIndexForTableView/LayoutSettingsView.m:
--------------------------------------------------------------------------------
1 | //
2 | // LayoutSettingsView.m
3 | // MJNIndexForTableView
4 | //
5 | // Created by Mateusz Nuckowski on 14/07/13.
6 | // Copyright (c) 2013 Mateusz Nuckowski. All rights reserved.
7 | //
8 |
9 | #import "LayoutSettingsView.h"
10 |
11 | @interface LayoutSettingsView ()
12 |
13 | @property (nonatomic, strong) UITextField *rangeDeflectionValue;
14 | @property (nonatomic, strong) UIStepper *rangeDeflectionStepper;
15 | @property (nonatomic, strong) UITextField *itemsDeflectionValue;
16 | @property (nonatomic, strong) UISlider *itemsDeflectionSlider;
17 | @property (nonatomic, strong) UITextField *rightMarginValue;
18 | @property (nonatomic, strong) UISlider *rightMarginSlider;
19 | @property (nonatomic, strong) UITextField *upperMarginValue;
20 | @property (nonatomic, strong) UISlider *upperMarginSlider;
21 | @property (nonatomic, strong) UITextField *lowerMarginValue;
22 | @property (nonatomic, strong) UISlider *lowerMarginSlider;
23 |
24 |
25 | @property (nonatomic, assign) NSTextAlignment aligment;
26 | @property (nonatomic, assign) BOOL darkening;
27 | @property (nonatomic, assign) BOOL fading;
28 | @property (nonatomic, assign) BOOL ergoHeight;
29 | @property (nonatomic, assign) int rangeOfDeflection;
30 | @property (nonatomic, assign) CGFloat maxDeflection;
31 | @property (nonatomic, assign) CGFloat rightMargin;
32 | @property (nonatomic, assign) CGFloat upperMargin;
33 | @property (nonatomic, assign) CGFloat lowerMargin;
34 |
35 | @property (nonatomic, assign) CGFloat prevX;
36 |
37 | @end
38 |
39 | @implementation LayoutSettingsView
40 |
41 | - (id)initWithFrame:(CGRect)frame
42 | {
43 | self = [super initWithFrame:frame];
44 | if (self) {
45 | // Initialization code
46 | }
47 | return self;
48 | }
49 |
50 | -(id)initWithDeflectionRange:(int)range
51 | maxDeflection:(CGFloat)maxDef
52 | itemAligment:(NSTextAlignment)aligment
53 | rightMargin:(CGFloat)rightM
54 | upperMargin:(CGFloat)upperM
55 | lowerMargin:(CGFloat)lowerM
56 | darkening:(BOOL)darkening
57 | fading:(BOOL)fading
58 | ergoHeight:(BOOL)ergo
59 |
60 | {
61 | if (self = [super initWithFrame:CGRectZero]) {
62 |
63 |
64 | self.rangeOfDeflection = range;
65 | self.maxDeflection = maxDef;
66 | self.aligment = aligment;
67 | self.rightMargin = rightM;
68 | self.upperMargin = upperM;
69 | self.lowerMargin = lowerM;
70 | self.darkening = darkening;
71 | self.fading = fading;
72 | self.ergoHeight = ergo;
73 |
74 | }
75 | [self drawElements];
76 | [self enabledDisabled];
77 |
78 | return self;
79 | }
80 |
81 | - (void)updateLayout
82 | {
83 | NSDictionary *settings = @{@"range":@(self.rangeOfDeflection), @"maxDef":@(self.maxDeflection), @"aligment":@(self.aligment), @"rightMargin":@(self.rightMargin), @"upperMargin":@(self.upperMargin), @"lowerMargin":@(self.lowerMargin), @"darkening":@(self.darkening), @"fading":@(self.fading), @"ergoHeight":@(self.ergoHeight)};
84 | [self.delegate layoutSettingForIndexItems:settings];
85 | }
86 |
87 | - (void) drawElements
88 | {
89 | // title label
90 | UILabel *title = [[UILabel alloc]initWithFrame:CGRectMake(20.0, 20.0, 210.0, 21.0)];
91 | title.backgroundColor = [UIColor clearColor];
92 | title.text = @"Items aligment";
93 | [self addSubview:title];
94 |
95 |
96 | // font name segmented control
97 | NSArray *aligmentNames = @[@"Left",@"Center",@"Right"];
98 |
99 |
100 | UISegmentedControl *aligmentSelector = [[UISegmentedControl alloc]initWithItems:aligmentNames];
101 | UIFont *font = [UIFont boldSystemFontOfSize:10.0];
102 | NSDictionary *attributes = @{NSFontAttributeName:font};
103 | [aligmentSelector setTitleTextAttributes:attributes
104 | forState:UIControlStateNormal];
105 | aligmentSelector.frame = CGRectMake(20.0, 54.0, 200, 40);
106 |
107 | if (self.aligment == NSTextAlignmentLeft) aligmentSelector.selectedSegmentIndex = 0;
108 | else if (self.aligment == NSTextAlignmentRight) aligmentSelector.selectedSegmentIndex = 2;
109 | else aligmentSelector.selectedSegmentIndex = 1;
110 |
111 | [aligmentSelector addTarget:self action:@selector(changeAligment:) forControlEvents:UIControlEventValueChanged];
112 | [self addSubview:aligmentSelector];
113 |
114 | // darkening label
115 | UILabel *darkeningLabel = [[UILabel alloc]initWithFrame:CGRectMake(20.0, 107.0, 90.0, 21.0)];
116 | darkeningLabel.backgroundColor = [UIColor clearColor];
117 | darkeningLabel.font = [UIFont systemFontOfSize: 15.0];
118 | darkeningLabel.text = @"darkening";
119 | [self addSubview:darkeningLabel];
120 |
121 | // fading label
122 | UILabel *fadingLabel = [[UILabel alloc]initWithFrame:CGRectMake(20.0, 142.0, 90.0, 21.0)];
123 | fadingLabel.backgroundColor = [UIColor clearColor];
124 | fadingLabel.font = [UIFont systemFontOfSize: 15.0];
125 | fadingLabel.text = @"fading";
126 | [self addSubview:fadingLabel];
127 |
128 | // ergo label
129 | UILabel *ergoLabel = [[UILabel alloc]initWithFrame:CGRectMake(20.0, 177.0, 100.0, 21.0)];
130 | ergoLabel.backgroundColor = [UIColor clearColor];
131 | ergoLabel.font = [UIFont systemFontOfSize: 15.0];
132 | ergoLabel.text = @"ergo height";
133 | [self addSubview:ergoLabel];
134 |
135 |
136 | // darkening switch
137 | UISwitch *darkeningSwitch = [[UISwitch alloc]initWithFrame:CGRectMake(141.0, 105.0, 79.0, 27.0)];
138 | darkeningSwitch.on = self.darkening;
139 | [darkeningSwitch addTarget:self action:@selector(darkeningChanged:) forControlEvents:UIControlEventValueChanged];
140 | [self addSubview:darkeningSwitch];
141 |
142 | // fading switch
143 | UISwitch *fadingSwitch = [[UISwitch alloc]initWithFrame:CGRectMake(141.0, 140.0, 79.0, 27.0)];
144 | fadingSwitch.on = self.fading;
145 | [fadingSwitch addTarget:self action:@selector(fadingChanged:) forControlEvents:UIControlEventValueChanged];
146 | [self addSubview:fadingSwitch];
147 |
148 | // ergo switch
149 | UISwitch *ergoSwitch = [[UISwitch alloc]initWithFrame:CGRectMake(141.0, 175.0, 79.0, 27.0)];
150 | ergoSwitch.on = self.ergoHeight;
151 | [ergoSwitch addTarget:self action:@selector(ergoChanged:) forControlEvents:UIControlEventValueChanged];
152 | [self addSubview:ergoSwitch];
153 |
154 |
155 | // Range label
156 | UILabel *rangeLabel = [[UILabel alloc]initWithFrame:CGRectMake(20.0, 212.0, 163.0, 21.0)];
157 | rangeLabel.font = [UIFont systemFontOfSize: 15.0];
158 | rangeLabel.text = @"Range of deflection";
159 | rangeLabel.backgroundColor = [UIColor clearColor];
160 | [self addSubview:rangeLabel];
161 |
162 | // rangeValue textField
163 | self.rangeDeflectionValue = [[UITextField alloc]initWithFrame:CGRectMake(175.0, 210.0, 45.0, 25.0)];
164 | self.rangeDeflectionValue.borderStyle = UITextBorderStyleRoundedRect;
165 | [self.rangeDeflectionValue setKeyboardType:UIKeyboardTypeNumbersAndPunctuation];
166 | self.rangeDeflectionValue.text = [NSString stringWithFormat:@"%d",self.rangeOfDeflection];
167 | [self.rangeDeflectionValue addTarget:self action:@selector(changeRangeValue:) forControlEvents:UIControlEventEditingChanged];
168 | [self addSubview:self.rangeDeflectionValue];
169 |
170 | // range stepper
171 | self.rangeDeflectionStepper = [[UIStepper alloc]initWithFrame:CGRectMake(126.0, 245.0, 94, 27.0)];
172 | self.rangeDeflectionStepper.minimumValue = 1;
173 | self.rangeDeflectionStepper.maximumValue = 10;
174 | self.rangeDeflectionStepper.stepValue = 1;
175 | self.rangeDeflectionStepper.value = [self.rangeDeflectionValue.text integerValue];
176 | [self.rangeDeflectionStepper addTarget:self action:@selector(rangePressed:) forControlEvents:UIControlEventValueChanged];
177 | [self addSubview:self.rangeDeflectionStepper];
178 |
179 |
180 | // Max deflection label
181 | UILabel *maxDefLabel = [[UILabel alloc]initWithFrame:CGRectMake(20.0, 280.0, 140.0, 16.0)];
182 | maxDefLabel.font = [UIFont systemFontOfSize: 12.0];
183 | maxDefLabel.text = @"Max. items deflection";
184 | maxDefLabel.backgroundColor = [UIColor clearColor];
185 | [self addSubview:maxDefLabel];
186 |
187 | // maxDeflection textField
188 | self.itemsDeflectionValue = [[UITextField alloc]initWithFrame:CGRectMake(150.0, 295.0, 70.0, 25.0)];
189 | self.itemsDeflectionValue.borderStyle = UITextBorderStyleRoundedRect;
190 | [self.itemsDeflectionValue setKeyboardType:UIKeyboardTypeNumbersAndPunctuation];
191 | self.itemsDeflectionValue.text = [NSString stringWithFormat:@"%.2f",self.maxDeflection];
192 | [self.itemsDeflectionValue addTarget:self action:@selector(changeDeflectionValue:) forControlEvents:UIControlEventEditingDidEnd];
193 | [self.itemsDeflectionValue addTarget:self action:@selector(moveUp) forControlEvents:UIControlEventEditingDidBegin];
194 |
195 | [self addSubview:self.itemsDeflectionValue];
196 |
197 | // maxDeflection slider
198 | self.itemsDeflectionSlider = [[UISlider alloc]initWithFrame:CGRectMake(20.0, 296.0, 120.0, 23.0)];
199 | self.itemsDeflectionSlider.minimumValue = 0.0;
200 | self.itemsDeflectionSlider.maximumValue = 300.0;
201 | self.itemsDeflectionSlider.value = [self.itemsDeflectionValue.text floatValue];
202 | [self.itemsDeflectionSlider addTarget:self action:@selector(itemsDefSliderChanged:) forControlEvents:UIControlEventValueChanged];
203 | [self addSubview:self.itemsDeflectionSlider];
204 |
205 |
206 | // rightMargin label
207 | UILabel *rightMarginLabel = [[UILabel alloc]initWithFrame:CGRectMake(20.0, 320.0, 140.0, 16.0)];
208 | rightMarginLabel.font = [UIFont systemFontOfSize: 12.0];
209 | rightMarginLabel.text = @"Right margin";
210 | rightMarginLabel.backgroundColor = [UIColor clearColor];
211 | [self addSubview:rightMarginLabel];
212 |
213 | // rightMarginValue textField
214 | self.rightMarginValue = [[UITextField alloc]initWithFrame:CGRectMake(150.0, 335.0, 70.0, 25.0)];
215 | self.rightMarginValue.borderStyle = UITextBorderStyleRoundedRect;
216 | [self.rightMarginValue setKeyboardType:UIKeyboardTypeNumbersAndPunctuation];
217 | self.rightMarginValue.text = [NSString stringWithFormat:@"%.2f",self.rightMargin];
218 | [self.rightMarginValue addTarget:self action:@selector(changerightMarginValue:) forControlEvents:UIControlEventEditingDidEnd];
219 | [self.rightMarginValue addTarget:self action:@selector(moveUp) forControlEvents:UIControlEventEditingDidBegin];
220 |
221 | [self addSubview:self.rightMarginValue];
222 |
223 | // rightMargin slider
224 | self.rightMarginSlider = [[UISlider alloc]initWithFrame:CGRectMake(20.0, 336.0, 120.0, 23.0)];
225 | self.rightMarginSlider.minimumValue = 0.0;
226 | self.rightMarginSlider.maximumValue = 50.0;
227 | self.rightMarginSlider.value = [self.rightMarginValue.text floatValue];
228 | [self.rightMarginSlider addTarget:self action:@selector(rightMarginSliderChanged:) forControlEvents:UIControlEventValueChanged];
229 | [self addSubview:self.rightMarginSlider];
230 |
231 |
232 | // upperMargin label
233 | UILabel *upperMarginLabel = [[UILabel alloc]initWithFrame:CGRectMake(20.0, 360.0, 140.0, 16.0)];
234 | upperMarginLabel.font = [UIFont systemFontOfSize: 12.0];
235 | upperMarginLabel.text = @"Upper margin";
236 | upperMarginLabel.backgroundColor = [UIColor clearColor];
237 | [self addSubview:upperMarginLabel];
238 |
239 | // upperMarginValue textField
240 | self.upperMarginValue = [[UITextField alloc]initWithFrame:CGRectMake(150.0, 375.0, 70.0, 25.0)];
241 | self.upperMarginValue.borderStyle = UITextBorderStyleRoundedRect;
242 | [self.upperMarginValue setKeyboardType:UIKeyboardTypeNumbersAndPunctuation];
243 | self.upperMarginValue.text = [NSString stringWithFormat:@"%.2f",self.upperMargin];
244 | [self.upperMarginValue addTarget:self action:@selector(changeupperMarginValue:) forControlEvents:UIControlEventEditingDidEnd];
245 | [self.upperMarginValue addTarget:self action:@selector(moveUp) forControlEvents:UIControlEventEditingDidBegin];
246 |
247 | [self addSubview:self.upperMarginValue];
248 |
249 | // upperMargin slider
250 | self.upperMarginSlider = [[UISlider alloc]initWithFrame:CGRectMake(20.0, 376.0, 120.0, 23.0)];
251 | self.upperMarginSlider.minimumValue = 0.0;
252 | self.upperMarginSlider.maximumValue = 150.0;
253 | self.upperMarginSlider.value = [self.upperMarginValue.text floatValue];
254 | [self.upperMarginSlider addTarget:self action:@selector(upperMarginSliderChanged:) forControlEvents:UIControlEventValueChanged];
255 | [self addSubview:self.upperMarginSlider];
256 |
257 |
258 | // lowerMargin label
259 | UILabel *lowerMarginLabel = [[UILabel alloc]initWithFrame:CGRectMake(20.0, 400.0, 140.0, 16.0)];
260 | lowerMarginLabel.font = [UIFont systemFontOfSize: 12.0];
261 | lowerMarginLabel.text = @"Lower margin";
262 | lowerMarginLabel.backgroundColor = [UIColor clearColor];
263 | [self addSubview:lowerMarginLabel];
264 |
265 | // lowerMarginValue textField
266 | self.lowerMarginValue = [[UITextField alloc]initWithFrame:CGRectMake(150.0, 415.0, 70.0, 25.0)];
267 | self.lowerMarginValue.borderStyle = UITextBorderStyleRoundedRect;
268 | [self.lowerMarginValue setKeyboardType:UIKeyboardTypeNumbersAndPunctuation];
269 | self.lowerMarginValue.text = [NSString stringWithFormat:@"%.2f",self.lowerMargin];
270 | [self.lowerMarginValue addTarget:self action:@selector(changelowerMarginValue:) forControlEvents:UIControlEventEditingDidEnd];
271 | [self.lowerMarginValue addTarget:self action:@selector(moveUp) forControlEvents:UIControlEventEditingDidBegin];
272 |
273 | [self addSubview:self.lowerMarginValue];
274 |
275 | // lowerMargin slider
276 | self.lowerMarginSlider = [[UISlider alloc]initWithFrame:CGRectMake(20.0, 416.0, 120.0, 23.0)];
277 | self.lowerMarginSlider.minimumValue = 0.0;
278 | self.lowerMarginSlider.maximumValue = 150.0;
279 | self.lowerMarginSlider.value = [self.lowerMarginValue.text floatValue];
280 | [self.lowerMarginSlider addTarget:self action:@selector(lowerMarginSliderChanged:) forControlEvents:UIControlEventValueChanged];
281 | [self addSubview:self.lowerMarginSlider];
282 |
283 | }
284 |
285 |
286 | #pragma mark uisegmentedcontrol change methods
287 | - (void)changeAligment:(UISegmentedControl *)sender
288 | {
289 | if (sender.selectedSegmentIndex == 0) self.aligment = NSTextAlignmentLeft;
290 | else if (sender.selectedSegmentIndex == 1) self.aligment = NSTextAlignmentCenter;
291 | else self.aligment = NSTextAlignmentRight;
292 | [self updateLayout];
293 | }
294 |
295 |
296 | #pragma mark uiswitch change methods
297 | - (void)darkeningChanged:(UISwitch *)sender
298 | {
299 | self.darkening = sender.on;
300 | [self updateLayout];
301 | }
302 |
303 | - (void)fadingChanged:(UISwitch *)sender
304 | {
305 | self.fading = sender.on;
306 | [self updateLayout];
307 | }
308 |
309 | - (void)ergoChanged:(UISwitch *)sender
310 | {
311 | self.ergoHeight = sender.on;
312 | [self enabledDisabled];
313 | [self updateLayout];
314 | }
315 |
316 | #pragma mark range change methods
317 | - (void)changeRangeValue:(UITextField *)sender
318 | {
319 | if ([sender.text floatValue] < 0) sender.text = @"0";
320 |
321 | self.rangeOfDeflection = (int)[sender.text integerValue];
322 | self.rangeDeflectionStepper.value = [sender.text integerValue];
323 | [self updateLayout];
324 | }
325 |
326 | - (void)rangePressed:(UIStepper *)sender
327 | {
328 | self.rangeOfDeflection = (int)self.rangeDeflectionStepper.value;
329 | self.rangeDeflectionValue.text = [NSString stringWithFormat:@"%d",(int)self.rangeDeflectionStepper.value];
330 | [self updateLayout];
331 | }
332 |
333 | #pragma mark deflection settings
334 | - (void)changeDeflectionValue:(UITextField *)sender
335 | {
336 | if ([sender.text floatValue] > self.itemsDeflectionSlider.maximumValue) sender.text = [NSString stringWithFormat:@"%.2f",self.itemsDeflectionSlider.maximumValue];
337 | if ([sender.text floatValue] < self.itemsDeflectionSlider.minimumValue) sender.text = [NSString stringWithFormat:@"%.2f",self.itemsDeflectionSlider.minimumValue];
338 |
339 | self.maxDeflection = [sender.text floatValue];
340 | self.itemsDeflectionSlider.value = [sender.text floatValue];
341 | [self updateLayout];
342 | }
343 |
344 | - (void)itemsDefSliderChanged:(UISlider *)sender
345 | {
346 | self.maxDeflection = sender.value;
347 | self.itemsDeflectionValue.text = [NSString stringWithFormat:@"%.2f",sender.value];
348 | [self updateLayout];
349 | }
350 |
351 |
352 | #pragma mark rightMargin settings
353 | - (void)changerightMarginValue:(UITextField *)sender
354 | {
355 | if ([sender.text floatValue] > self.rightMarginSlider.maximumValue) sender.text = [NSString stringWithFormat:@"%.2f",self.rightMarginSlider.maximumValue];
356 | if ([sender.text floatValue] < self.rightMarginSlider.minimumValue) sender.text = [NSString stringWithFormat:@"%.2f",self.rightMarginSlider.minimumValue];
357 |
358 | self.rightMargin = [sender.text floatValue];
359 | self.rightMarginSlider.value = [sender.text floatValue];
360 | [self updateLayout];
361 | }
362 |
363 | - (void)rightMarginSliderChanged:(UISlider *)sender
364 | {
365 | self.rightMargin = sender.value;
366 | self.rightMarginValue.text = [NSString stringWithFormat:@"%.2f",sender.value];
367 | [self updateLayout];
368 | }
369 |
370 | #pragma mark upperMargin settings
371 | - (void)changeupperMarginValue:(UITextField *)sender
372 | {
373 | if ([sender.text floatValue] > self.upperMarginSlider.maximumValue) sender.text = [NSString stringWithFormat:@"%.2f",self.upperMarginSlider.maximumValue];
374 | if ([sender.text floatValue] < self.upperMarginSlider.minimumValue) sender.text = [NSString stringWithFormat:@"%.2f",self.upperMarginSlider.minimumValue];
375 |
376 | self.upperMargin = [sender.text floatValue];
377 | self.upperMarginSlider.value = [sender.text floatValue];
378 | [self updateLayout];
379 | }
380 |
381 | - (void)upperMarginSliderChanged:(UISlider *)sender
382 | {
383 | self.upperMargin = sender.value;
384 | self.upperMarginValue.text = [NSString stringWithFormat:@"%.2f",sender.value];
385 | [self updateLayout];
386 | }
387 |
388 | #pragma mark lowerMargin settings
389 | - (void)changelowerMarginValue:(UITextField *)sender
390 | {
391 | if ([sender.text floatValue] > self.lowerMarginSlider.maximumValue) sender.text = [NSString stringWithFormat:@"%.2f",self.lowerMarginSlider.maximumValue];
392 | if ([sender.text floatValue] < self.lowerMarginSlider.minimumValue) sender.text = [NSString stringWithFormat:@"%.2f",self.lowerMarginSlider.minimumValue];
393 |
394 | self.lowerMargin = [sender.text floatValue];
395 | self.lowerMarginSlider.value = [sender.text floatValue];
396 | [self updateLayout];
397 | }
398 |
399 | - (void)lowerMarginSliderChanged:(UISlider *)sender
400 | {
401 | self.lowerMargin = sender.value;
402 | self.lowerMarginValue.text = [NSString stringWithFormat:@"%.2f",sender.value];
403 | [self updateLayout];
404 | }
405 |
406 |
407 | - (void)enabledDisabled
408 | {
409 | self.upperMarginSlider.enabled = !self.ergoHeight;
410 | self.lowerMarginSlider.enabled = !self.ergoHeight;
411 | self.upperMarginValue.enabled = !self.ergoHeight;
412 | self.lowerMarginValue.enabled = !self.ergoHeight;
413 | }
414 |
415 | #pragma mark moving view up and down
416 | - (void) moveUp
417 | {
418 | if (self.frame.origin.y == 0.0) {
419 | [UIView beginAnimations:@"moveUp" context:NULL];
420 | self.frame = CGRectOffset(self.frame, 0.0, -200.0);
421 | [UIView commitAnimations];
422 | }
423 | }
424 |
425 | - (void) moveDown
426 | {
427 | if (self.frame.origin.y < 0.0) {
428 | [UIView beginAnimations:@"moveDown" context:NULL];
429 | self.frame = CGRectOffset(self.frame, 0.0, 200.0);
430 | [UIView commitAnimations];
431 | }
432 | }
433 |
434 |
435 | #pragma mark methods for keyboard dismissal
436 | - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
437 | {
438 | CGPoint tappedPt = [[touches anyObject] locationInView: self];
439 | self.prevX = tappedPt.x;
440 |
441 |
442 | for (id subView in self.subviews) {
443 | if ([subView isMemberOfClass:[UITextField class]]) {
444 | UITextField *textField = subView;
445 | [textField resignFirstResponder];
446 | }
447 |
448 | }
449 | [self moveDown];
450 | }
451 |
452 |
453 |
454 |
455 |
456 | - (BOOL)textFieldShouldReturn:(UITextField *)textField
457 | {
458 | [textField resignFirstResponder];
459 | [self moveDown];
460 | return YES;
461 | }
462 |
463 | - (void) willMoveToSuperview:(UIView *)newSuperview
464 | {
465 | for (id subView in self.subviews) {
466 | if ([subView isMemberOfClass:[UITextField class]]) {
467 | UITextField *textField = subView;
468 | textField.delegate = self;
469 | }
470 | }
471 | self.upperMarginSlider.maximumValue = self.bounds.size.height / 2.0 - 100.0;
472 | self.lowerMarginSlider.maximumValue = self.bounds.size.height / 2.0 - 100.0;
473 |
474 | }
475 |
476 | // method for swipe to close
477 |
478 | - (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
479 | {
480 | CGPoint tappedPt = [[touches anyObject] locationInView: self];
481 | CGFloat currentX = tappedPt.x;
482 | if (self.prevX - currentX > 20.0) [self.delegate close];
483 | }
484 |
485 | /*
486 | // Only override drawRect: if you perform custom drawing.
487 | // An empty implementation adversely affects performance during animation.
488 | - (void)drawRect:(CGRect)rect
489 | {
490 | // Drawing code
491 | }
492 | */
493 |
494 | @end
495 |
--------------------------------------------------------------------------------
/MJNIndexForTableView/MJNIndexForTableDemoVC.h:
--------------------------------------------------------------------------------
1 | //
2 | // MJNIndexForTableDemoVC.h
3 | // MJNIndexForTableView
4 | //
5 | // Created by mateusz on 12.07.2013.
6 | // Copyright (c) 2013 Mateusz Nuckowski. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface MJNIndexForTableDemoVC : UIViewController
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/MJNIndexForTableView/MJNIndexForTableDemoVC.m:
--------------------------------------------------------------------------------
1 | //
2 | // MJNIndexForTableDemoVC.m
3 | // MJNIndexForTableView
4 | //
5 | // Created by mateusz on 12.07.2013.
6 | // Copyright (c) 2013 Mateusz Nuckowski. All rights reserved.
7 | //
8 |
9 | #import "MJNIndexForTableDemoVC.h"
10 | #import "MJNIndexView.h"
11 | #import "FontSettingsView.h"
12 | #import "CurtainSettings.h"
13 | #import "LayoutSettingsView.h"
14 | #import "ExamplesSettings.h"
15 | #import
16 |
17 | #define CRAYON_NAME(CRAYON) [[CRAYON componentsSeparatedByString:@"#"] objectAtIndex:0]
18 |
19 |
20 |
21 | @interface MJNIndexForTableDemoVC ()
24 |
25 |
26 | // properties for section array
27 | @property (nonatomic, strong) NSString *pathname;
28 | @property (nonatomic, strong) NSArray *crayons;
29 | @property (nonatomic, strong) NSString *alphaString;
30 | @property (nonatomic, strong) NSMutableArray *sectionArray;
31 |
32 | // properties for tableView
33 | @property (nonatomic, strong) UITableView *tableView;
34 | @property (nonatomic, strong) UIColor *tableColor;
35 | @property (nonatomic, strong) UIColor *tableTextColor;
36 | @property (nonatomic, strong) UIColor *tableSeparatorColor;
37 | @property (nonatomic, strong) UIColor *tableHeaderColor;
38 | @property (nonatomic, strong) UIColor *tableHeaderTextColor;
39 | @property (nonatomic, strong) UIFont *font;
40 |
41 |
42 | // MJNIndexView
43 | @property (nonatomic, strong) MJNIndexView *indexView;
44 |
45 | // settings, scrollView
46 | @property (nonatomic, strong) UIView *settingsView;
47 | @property (nonatomic, assign) BOOL settingsAreVisible;
48 | @property (nonatomic, strong) UIScrollView *scrollView;
49 | @property (nonatomic, strong) UIPageControl *pageControl;
50 |
51 | // properties for exampleView delegate
52 | @property (nonatomic, strong) NSArray * allExamples;
53 |
54 |
55 |
56 | #pragma mark all properties from MJNIndexView
57 |
58 | // set this to NO if you want to get selected items during the pan (default is YES)
59 | @property (nonatomic, assign) BOOL getSelectedItemsAfterPanGestureIsFinished;
60 |
61 | // set the font of the selected index item (usually you should choose the same font with a bold style and much larger)
62 | // (default is the same font as previous one with size 40.0 points)
63 | @property (nonatomic, strong) UIFont *selectedItemFont;
64 |
65 | // set the color for index items
66 | @property (nonatomic, strong) UIColor *fontColor;
67 |
68 | // set if items in index are going to darken during a pan (default is YES)
69 | @property (nonatomic, assign) BOOL darkening;
70 |
71 | // set if items in index are going ti fade during a pan (default is YES)
72 | @property (nonatomic, assign) BOOL fading;
73 |
74 | // set the color for the selected index item
75 | @property (nonatomic, strong) UIColor *selectedItemFontColor;
76 |
77 | // set index items aligment (NSTextAligmentLeft, NSTextAligmentCenter or NSTextAligmentRight - default is NSTextAligmentCenter)
78 | @property (nonatomic, assign) NSTextAlignment itemsAligment;
79 |
80 | // set the right margin of index items (default is 10.0)
81 | @property (nonatomic, assign) CGFloat rightMargin;
82 |
83 | // set the upper margin of index items (default is 20.0)
84 | // please remember that margins are set for the largest size of selected item font
85 | @property (nonatomic, assign) CGFloat upperMargin;
86 |
87 | // set the lower margin of index items (default is 20.0)
88 | // please remember that margins are set for the largest size of selected item font
89 | @property (nonatomic, assign) CGFloat lowerMargin;
90 |
91 | // set the maximum amount for item deflection (default is 75.0)
92 | @property (nonatomic,assign) CGFloat maxItemDeflection;
93 |
94 | // set the number of items deflected below and above the selected one (default is 5)
95 | @property (nonatomic, assign) int rangeOfDeflection;
96 |
97 | // set the curtain color if you want a curtain to appear (default is none)
98 | @property (nonatomic, strong) UIColor *curtainColor;
99 |
100 | // set the amount of fading for the curtain between 0 to 1 (default is 0.2)
101 | @property (nonatomic, assign) CGFloat curtainFade;
102 |
103 | // set if you need a curtain not to hide completely
104 | @property (nonatomic, assign) BOOL curtainStays;
105 |
106 | // set if you want a curtain to move while panning (default is NO)
107 | @property (nonatomic, assign) BOOL curtainMoves;
108 |
109 | // set if you need curtain to have the same upper and lower margins (default is NO)
110 | @property (nonatomic, assign) BOOL curtainMargins;
111 |
112 | // set this property to YES and it will automatically set margins so that gaps between items are 5.0 points (default is YES)
113 | @property BOOL ergonomicHeight;
114 |
115 | @end
116 |
117 | @implementation MJNIndexForTableDemoVC
118 |
119 | - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
120 | {
121 | self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
122 | if (self) {
123 | // Custom initialization
124 | }
125 | return self;
126 | }
127 |
128 |
129 | #pragma mark viewcontroller life cycle methods
130 | - (void)viewDidLoad
131 | {
132 | [super viewDidLoad];
133 | self.view.backgroundColor = [UIColor whiteColor];
134 |
135 | // setting all examples for the first example
136 | self.allExamples = @[@(1), @(0), @(0), @(0), @(0)];
137 |
138 | // load first sit of data to table
139 | [self firstTableExample];
140 | //[self secondTableExample];
141 |
142 | // initialise tableView
143 | self.tableView = [[UITableView alloc] initWithFrame:CGRectMake(0.0, 40.0, self.view.bounds.size.width, self.view.bounds.size.height - 60.0)];
144 | [self.tableView registerClass:[UITableViewCell class]forCellReuseIdentifier:@"cell"];
145 | [self.tableView registerClass:[UITableViewHeaderFooterView class] forHeaderFooterViewReuseIdentifier:@"header"];
146 | self.tableView.dataSource = self;
147 | self.tableView.delegate = self;
148 | self.tableView.showsVerticalScrollIndicator = NO;
149 | [self.view addSubview:self.tableView];
150 |
151 | // initialise MJNIndexView
152 | self.indexView = [[MJNIndexView alloc]initWithFrame:self.tableView.frame];
153 | self.indexView.dataSource = self;
154 | [self firstAttributesForMJNIndexView];
155 | [self readAttributes];
156 | [self.view addSubview:self.indexView];
157 |
158 |
159 | // adding settings button
160 | UIButton *settingsButton = [UIButton buttonWithType:UIButtonTypeCustom];
161 | [settingsButton setImage:[UIImage imageNamed:@"settingsButton.png"] forState:UIControlStateNormal];
162 | [settingsButton addTarget:self action:@selector(close) forControlEvents:UIControlEventTouchDown];
163 | settingsButton.frame = CGRectMake(0.0, 0.0, 20.0, 40.0);
164 | settingsButton.center = CGPointMake(settingsButton.center.x, self.view.bounds.size.height / 2.0);
165 | [self.view addSubview:settingsButton];
166 |
167 | // adding view for settings
168 | self.settingsView = [[UIView alloc] initWithFrame:CGRectMake(-240.0, 40.0, 240.0, self.view.bounds.size.height - 60.0)];
169 | CAGradientLayer *gradientLayer = [CAGradientLayer layer];
170 | gradientLayer.frame = CGRectMake(0.0,0.0,240.0,self.settingsView.bounds.size.height);
171 | UIColor *firstColor = [UIColor colorWithRed:0.8 green:0.8 blue:0.8 alpha:1.0];
172 | UIColor *secondColor = [UIColor colorWithRed:0.8 green:0.8 blue:0.8 alpha:0.0];
173 | gradientLayer.colors = @[(id)firstColor.CGColor, (id)secondColor.CGColor];
174 | gradientLayer.startPoint = CGPointMake(0.55, 0.0);
175 | gradientLayer.endPoint = CGPointMake(1.0, 0.0);
176 | [self.settingsView.layer insertSublayer:gradientLayer atIndex:0];
177 | [self.view addSubview:self.settingsView];
178 | self.settingsAreVisible = NO;
179 |
180 | // adding scrollview to settings view
181 |
182 | self.scrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0.0, 0.0, 240.0, self.view.bounds.size.height - 20.0)];
183 | self.scrollView.scrollEnabled = NO;
184 | self.scrollView.pagingEnabled = YES;
185 | self.scrollView.delegate = self;
186 | self.scrollView.contentSize = CGSizeMake(self.scrollView.bounds.size.width, self.scrollView.bounds.size.height);
187 | [self.settingsView addSubview:self.scrollView];
188 |
189 | // adding pagecontrol to setting view
190 |
191 | self.pageControl = [[UIPageControl alloc]initWithFrame:CGRectMake(0.0, 0.0, 240.0, 5.0)];
192 | self.pageControl.center = CGPointMake(self.scrollView.center.x, self.settingsView.bounds.size.height - 15.0);
193 | self.pageControl.pageIndicatorTintColor = [UIColor whiteColor];
194 | self.pageControl.currentPageIndicatorTintColor = [UIColor colorWithRed:0.0 green:105.0/255.0 blue:240.0/255.0 alpha:1.0];
195 | self.pageControl.numberOfPages = 1;
196 | self.pageControl.currentPage = 0;
197 | [self.pageControl addTarget:self action:@selector(changePage) forControlEvents:UIControlEventValueChanged];
198 | [self.settingsView addSubview:self.pageControl];
199 |
200 | // adding close button
201 | UIButton *closeButton = [UIButton buttonWithType:UIButtonTypeCustom];
202 | closeButton.frame = CGRectMake(200.0, 0.0, 40.0, 40.0);
203 | [closeButton setImage: [UIImage imageNamed:@"closeButton.png"] forState:UIControlStateNormal];
204 |
205 | [closeButton addTarget:self action:@selector(close) forControlEvents:UIControlEventTouchDown];
206 | [self.settingsView addSubview:closeButton];
207 |
208 | // adding prev button
209 | UIButton *prevButton = [UIButton buttonWithType:UIButtonTypeCustom];
210 | prevButton.frame = CGRectMake(0.0, self.settingsView.bounds.size.height - 30.0, 40.0, 30.0);
211 | [prevButton setImage: [UIImage imageNamed:@"prevButton.png"] forState:UIControlStateNormal];
212 | [prevButton addTarget:self action:@selector(changeToPreviousPage) forControlEvents:UIControlEventTouchDown];
213 | [self.settingsView addSubview:prevButton];
214 |
215 | // adding next button
216 | UIButton *nextButton = [UIButton buttonWithType:UIButtonTypeCustom];
217 | nextButton.frame = CGRectMake(200.0, self.settingsView.bounds.size.height - 30.0, 40.0, 30.0);
218 | [nextButton setImage:[UIImage imageNamed:@"nextButton.png"] forState:UIControlStateNormal];
219 | [nextButton addTarget:self action:@selector(changeToNextPage) forControlEvents:UIControlEventTouchDown];
220 | [self.settingsView addSubview:nextButton];
221 |
222 | }
223 |
224 | - (void)didReceiveMemoryWarning
225 | {
226 | [super didReceiveMemoryWarning];
227 | // Dispose of any resources that can be recreated.
228 | }
229 |
230 |
231 | #pragma mark reading/writting attributes for MJNIndexItemsForTableView
232 |
233 | - (void)readAttributes
234 | {
235 | self.getSelectedItemsAfterPanGestureIsFinished = self.indexView.getSelectedItemsAfterPanGestureIsFinished;
236 | self.font = self.indexView.font;
237 | self.selectedItemFont = self.indexView.selectedItemFont;
238 | self.fontColor = self.indexView.fontColor;
239 | self.selectedItemFontColor = self.indexView.selectedItemFontColor;
240 | self.darkening = self.indexView.darkening;
241 | self.fading = self.indexView.fading;
242 | self.itemsAligment = self.indexView.itemsAligment;
243 | self.rightMargin = self.indexView.rightMargin;
244 | self.upperMargin = self.indexView.upperMargin;
245 | self.lowerMargin = self.indexView.lowerMargin;
246 | self.maxItemDeflection = self.indexView.maxItemDeflection;
247 | self.rangeOfDeflection = self.indexView.rangeOfDeflection;
248 | self.curtainColor = self.indexView.curtainColor;
249 | self.curtainFade = self.indexView.curtainFade;
250 | self.curtainMargins = self.indexView.curtainMargins;
251 | self.curtainStays = self.indexView.curtainStays;
252 | self.curtainMoves = self.indexView.curtainMoves;
253 | self.ergonomicHeight = self.indexView.ergonomicHeight;
254 | }
255 |
256 | - (void)writeAttributes
257 | {
258 | self.indexView.getSelectedItemsAfterPanGestureIsFinished = self.getSelectedItemsAfterPanGestureIsFinished;
259 | self.indexView.font = self.font;
260 | self.indexView.selectedItemFont = self.selectedItemFont;
261 | self.indexView.fontColor = self.fontColor;
262 | self.indexView.selectedItemFontColor = self.selectedItemFontColor;
263 | self.indexView.darkening = self.darkening;
264 | self.indexView.fading = self.fading;
265 | self.indexView.itemsAligment = self.itemsAligment;
266 | self.indexView.rightMargin = self.rightMargin;
267 | self.indexView.upperMargin = self.upperMargin;
268 | self.indexView.lowerMargin = self.lowerMargin;
269 | self.indexView.maxItemDeflection = self.maxItemDeflection;
270 | self.indexView.rangeOfDeflection = self.rangeOfDeflection;
271 | self.indexView.curtainColor = self.curtainColor;
272 | self.indexView.curtainFade = self.curtainFade;
273 | self.indexView.curtainMargins = self.curtainMargins;
274 | self.indexView.curtainStays = self.curtainStays;
275 | self.indexView.curtainMoves = self.curtainMoves;
276 | self.indexView.ergonomicHeight = self.ergonomicHeight;
277 | }
278 |
279 |
280 | #pragma mark settigns examples of tableView and MJNIndexView
281 |
282 |
283 | - (void)firstTableExample
284 | {
285 | self.pathname = [[NSBundle mainBundle] pathForResource:@"crayons" ofType:@"txt"];
286 | self.tableColor = [UIColor whiteColor];
287 | self.tableTextColor = [UIColor blackColor];
288 | self.tableSeparatorColor = [UIColor colorWithWhite:0.9 alpha:1.0];
289 | self.tableHeaderColor = [UIColor colorWithRed:80.0/255.0 green:215.0/255.0 blue:250.0/255.0 alpha:1.0];
290 | self.tableHeaderTextColor = [UIColor whiteColor];
291 | [self refreshTable];
292 | }
293 |
294 | - (void)firstAttributesForMJNIndexView
295 | {
296 |
297 | self.indexView.getSelectedItemsAfterPanGestureIsFinished = YES;
298 | self.indexView.font = [UIFont fontWithName:@"HelveticaNeue" size:13.0];
299 | self.indexView.selectedItemFont = [UIFont fontWithName:@"HelveticaNeue-Bold" size:40.0];
300 | self.indexView.backgroundColor = [UIColor clearColor];
301 | self.indexView.curtainColor = nil;
302 | self.indexView.curtainFade = 0.0;
303 | self.indexView.curtainStays = NO;
304 | self.indexView.curtainMoves = YES;
305 | self.indexView.curtainMargins = NO;
306 | self.indexView.ergonomicHeight = NO;
307 | self.indexView.upperMargin = 22.0;
308 | self.indexView.lowerMargin = 22.0;
309 | self.indexView.rightMargin = 10.0;
310 | self.indexView.itemsAligment = NSTextAlignmentCenter;
311 | self.indexView.maxItemDeflection = 100.0;
312 | self.indexView.rangeOfDeflection = 5;
313 | self.indexView.fontColor = [UIColor colorWithRed:0.3 green:0.3 blue:0.3 alpha:1.0];
314 | self.indexView.selectedItemFontColor = [UIColor colorWithRed:0.0 green:0.0 blue:0.0 alpha:1.0];
315 | self.indexView.darkening = NO;
316 | self.indexView.fading = YES;
317 |
318 | }
319 |
320 | - (void)secondTableExample
321 | {
322 | self.pathname = [[NSBundle mainBundle] pathForResource:@"crayons2" ofType:@"txt"];
323 | // initialising of MJNIndexForTableView
324 | self.tableColor = [UIColor blackColor];
325 | self.tableTextColor = [UIColor whiteColor];
326 | self.tableSeparatorColor = [UIColor colorWithRed:0.2 green:0.2 blue:0.2 alpha:1.0];
327 | self.tableHeaderColor = [UIColor orangeColor];
328 | self.tableHeaderTextColor = [UIColor blackColor];
329 |
330 |
331 | [self refreshTable];
332 |
333 | }
334 |
335 | - (void)secondAttributesForMJNIndexView
336 | {
337 | self.indexView.getSelectedItemsAfterPanGestureIsFinished = NO;
338 | self.indexView.font = [UIFont fontWithName:@"GillSans" size:19.0];
339 | self.indexView.selectedItemFont = [UIFont fontWithName:@"GillSans-Bold" size:60.0];
340 | self.indexView.backgroundColor = [UIColor clearColor];
341 | self.indexView.curtainColor = [UIColor colorWithRed:0.0 green:0.0 blue:0.0 alpha:1.0];
342 | self.indexView.curtainFade = 0.0;
343 | self.indexView.curtainStays = YES;
344 | self.indexView.curtainMoves = YES;
345 | self.indexView.curtainMargins = NO;
346 | self.indexView.ergonomicHeight = NO;
347 | self.indexView.upperMargin = 30.0;
348 | self.indexView.lowerMargin = 124.0;
349 | self.indexView.rightMargin = 10.0;
350 | self.indexView.itemsAligment = NSTextAlignmentLeft;
351 | self.indexView.maxItemDeflection = 80.0;
352 | self.indexView.rangeOfDeflection = 3;
353 | self.indexView.fontColor = [UIColor colorWithRed:1.0 green:1.0 blue:1.0 alpha:1.0];
354 | self.indexView.selectedItemFontColor = [UIColor orangeColor];
355 | self.indexView.darkening = YES;
356 | self.indexView.fading = NO;
357 | }
358 |
359 | - (void)thirdTableExample
360 | {
361 | self.pathname = [[NSBundle mainBundle] pathForResource:@"crayons" ofType:@"txt"];
362 | self.tableColor = [UIColor colorWithRed:230.0/255.0 green:245.0/255.0 blue:255.0/255.0 alpha:1.0];
363 | self.tableTextColor = [UIColor colorWithRed:0.0/255.0 green:55.0/255.0 blue:85.0/255.0 alpha:1.0];
364 | self.tableSeparatorColor = [UIColor colorWithRed:90.0/255.0 green:195.0/255.0 blue:255.0/255.0 alpha:1.0];
365 | self.tableHeaderColor = [UIColor colorWithRed:0.0/255.0 green:135.0/255.0 blue:215.0/255.0 alpha:1.0];
366 | self.tableHeaderTextColor = [UIColor whiteColor];
367 | [self refreshTable];
368 | }
369 |
370 | - (void)thirdAttributesForMJNIndexView
371 | {
372 | self.indexView.getSelectedItemsAfterPanGestureIsFinished = YES;
373 | self.indexView.font = [UIFont fontWithName:@"TimesNewRomanPSMT" size:17.0];
374 | self.indexView.selectedItemFont = [UIFont fontWithName:@"TimesNewRomanPS-BoldMT" size:30.0];
375 | self.indexView.backgroundColor = [UIColor clearColor];
376 | self.indexView.curtainColor = [UIColor colorWithRed:230.0/255.0 green:245.0/255.0 blue:255.0/255.0 alpha:0.8];
377 | self.indexView.curtainFade = 0.2;
378 | self.indexView.curtainStays = YES;
379 | self.indexView.curtainMoves = YES;
380 | self.indexView.curtainMargins = NO;
381 | self.indexView.ergonomicHeight = NO;
382 | self.indexView.upperMargin = 10.0;
383 | self.indexView.lowerMargin = 10.0;
384 | self.indexView.rightMargin = 10.0;
385 | self.indexView.itemsAligment = NSTextAlignmentRight;
386 | self.indexView.maxItemDeflection = 100.0;
387 | self.indexView.rangeOfDeflection = 5;
388 | self.indexView.fontColor = [UIColor colorWithRed:0.0/255.0 green:105.0/255.0 blue:165.0/255.0 alpha:1.0];;
389 | self.indexView.selectedItemFontColor = [UIColor colorWithRed:0.0/255.0 green:35.0/255.0 blue:55.0/255.0 alpha:1.0];
390 | self.indexView.darkening = NO;
391 | self.indexView.fading = YES;
392 | }
393 |
394 | - (void)fourthTableExample
395 | {
396 | self.pathname = [[NSBundle mainBundle] pathForResource:@"crayons" ofType:@"txt"];
397 | self.tableColor = [UIColor whiteColor];
398 | self.tableTextColor = [UIColor colorWithRed:45.0/255.0 green:10.0/255.0 blue:125.0/255.0 alpha:1.0];
399 | self.tableSeparatorColor = [UIColor colorWithRed:235.0/255.0 green:205.0/255.0 blue:255.0/255.0 alpha:1.0];
400 | self.tableHeaderColor = [UIColor colorWithRed:185.0/255.0 green:95.0/255.0 blue:250.0/255.0 alpha:1.0];
401 | self.tableHeaderTextColor = [UIColor colorWithRed:75.0/255.0 green:10.0/255.0 blue:120.0/255.0 alpha:1.0];
402 | [self refreshTable];
403 | }
404 |
405 |
406 | - (void)fourthAttributesForMJNIndexView
407 | {
408 | self.indexView.getSelectedItemsAfterPanGestureIsFinished = NO;
409 | self.indexView.font = [UIFont fontWithName:@"HelveticaNeue" size:15.0];
410 | self.indexView.selectedItemFont = [UIFont fontWithName:@"HelveticaNeue-Bold" size:50.0];
411 | self.indexView.backgroundColor = [UIColor clearColor];
412 | self.indexView.curtainColor = [UIColor colorWithRed:1.0 green:1.0 blue:1.0 alpha:0.7];
413 | self.indexView.curtainFade = 0.0;
414 | self.indexView.curtainStays = YES;
415 | self.indexView.curtainMoves = YES;
416 | self.indexView.curtainMargins = NO;
417 | self.indexView.ergonomicHeight = NO;
418 | self.indexView.upperMargin = 10.0;
419 | self.indexView.lowerMargin = 10.0;
420 | self.indexView.rightMargin = 10.0;
421 | self.indexView.itemsAligment = NSTextAlignmentCenter;
422 | self.indexView.maxItemDeflection = 100.0;
423 | self.indexView.rangeOfDeflection = 5;
424 | self.indexView.fontColor = [UIColor colorWithRed:5.0/255.0 green:100.0/255.0 blue:90.0/255.0 alpha:1.0];;
425 | self.indexView.selectedItemFontColor = [UIColor colorWithRed:75.0/255.0 green:10.0/255.0 blue:120.0/255.0 alpha:1.0];
426 | self.indexView.darkening = NO;
427 | self.indexView.fading = YES;
428 | }
429 |
430 |
431 | - (void)fifthTableExample
432 | {
433 | self.pathname = [[NSBundle mainBundle] pathForResource:@"crayons2" ofType:@"txt"];
434 | self.tableColor = [UIColor colorWithWhite:0.8 alpha:1.0];
435 | self.tableTextColor = [UIColor colorWithWhite:0.3 alpha:1.0];
436 | self.tableSeparatorColor = [UIColor colorWithWhite:0.75 alpha:1.0];;
437 | self.tableHeaderColor = [UIColor colorWithWhite:0.5 alpha:1.0];;
438 | self.tableHeaderTextColor = [UIColor colorWithWhite:0.9 alpha:1.0];;
439 | [self refreshTable];
440 | }
441 |
442 |
443 | - (void)fifthAttributesForMJNIndexView
444 | {
445 | self.indexView.getSelectedItemsAfterPanGestureIsFinished = YES;
446 | self.indexView.font = [UIFont fontWithName:@"TimesNewRomanPSMT" size:17.0];
447 | self.indexView.selectedItemFont = [UIFont fontWithName:@"TimesNewRomanPS-BoldMT" size:40.0];
448 | self.indexView.backgroundColor = [UIColor clearColor];
449 | self.indexView.curtainColor = nil;
450 | self.indexView.curtainFade = 0.0;
451 | self.indexView.curtainStays = NO;
452 | self.indexView.curtainMoves = YES;
453 | self.indexView.curtainMargins = NO;
454 | self.indexView.ergonomicHeight = NO;
455 | self.indexView.upperMargin = 50.0;
456 | self.indexView.lowerMargin = 50.0;
457 | self.indexView.rightMargin = 10.0;
458 | self.indexView.itemsAligment = NSTextAlignmentRight;
459 | self.indexView.maxItemDeflection = 140.0;
460 | self.indexView.rangeOfDeflection = 2;
461 | self.indexView.fontColor = [UIColor colorWithRed:0.2 green:0.2 blue:0.2 alpha:1.0];;
462 | self.indexView.selectedItemFontColor = [UIColor colorWithRed:0.0 green:0.0 blue:0.0 alpha:1.0];
463 | self.indexView.darkening = NO;
464 | self.indexView.fading = YES;
465 | }
466 |
467 |
468 | // refreshing table with a contents of file stored in self.pathname
469 | - (void)refreshTable
470 | {
471 | NSArray *rawCrayons = [[NSString stringWithContentsOfFile:self.pathname encoding:NSUTF8StringEncoding error:nil] componentsSeparatedByString:@"\n"];
472 | NSMutableArray *crayonColors = [NSMutableArray new];
473 |
474 | for (NSString *string in rawCrayons) [crayonColors addObject:CRAYON_NAME(string)];
475 |
476 | self.alphaString = @"";
477 | self.crayons = crayonColors;
478 | self.sectionArray = [NSMutableArray array];
479 |
480 |
481 | int numberOfFirstLetters = [self countFirstLettersInArray:self.crayons];
482 |
483 | for (int i=0; i< numberOfFirstLetters; i++) {
484 | [self.sectionArray addObject:[self itemsInSection:i]];
485 | }
486 | [self.tableView setSeparatorColor:self.tableSeparatorColor];
487 | [self.tableView reloadData];
488 | [self.tableView reloadSectionIndexTitles];
489 | [self.indexView refreshIndexItems];
490 | [self.tableView scrollToRowAtIndexPath:[NSIndexPath indexPathForItem:0 inSection:[self.sectionArray count] -1] atScrollPosition:UITableViewScrollPositionTop animated:NO];
491 |
492 | [self.tableView scrollToRowAtIndexPath:[NSIndexPath indexPathForItem:0 inSection:0] atScrollPosition:UITableViewScrollPositionTop animated:YES];
493 | }
494 |
495 |
496 | // initialising modules for settings
497 | - (void) initSettingsModules
498 | {
499 | ExamplesSettings *exampleSetting = [[ExamplesSettings alloc]initWithExamples:self.allExamples andGettingSelectedAfterPan:self.getSelectedItemsAfterPanGestureIsFinished];
500 | exampleSetting.frame = CGRectMake(0.0, 0.0, 240.0, self.settingsView.bounds.size.height);
501 | exampleSetting.delegate = self;
502 |
503 |
504 | FontSettingsView *fontSetting = [[FontSettingsView alloc]initWithFont:self.font fontColor:self.fontColor forSelectedItem:NO];
505 | fontSetting.frame = CGRectMake(0.0, 0.0, 240.0, self.settingsView.bounds.size.height);
506 | fontSetting.delegate = self;
507 |
508 |
509 | FontSettingsView *selectedFontSettings = [[FontSettingsView alloc]initWithFont:self.selectedItemFont fontColor:self.selectedItemFontColor forSelectedItem:YES];
510 | selectedFontSettings.frame = CGRectMake(0.0, 0.0, 240.0, self.settingsView.bounds.size.height);
511 | selectedFontSettings.delegate = self;
512 |
513 |
514 | CurtainSettings *curtainSettings = [[CurtainSettings alloc]initWithCurtainColor:self.curtainColor fade:self.curtainFade margins:self.curtainMargins stays:self.curtainStays];
515 | curtainSettings.delegate = self;
516 | curtainSettings.frame = CGRectMake(0.0, 0.0, 240.0, self.settingsView.bounds.size.height);
517 |
518 | LayoutSettingsView *layoutSettings = [[LayoutSettingsView alloc] initWithDeflectionRange:self.rangeOfDeflection maxDeflection:self.maxItemDeflection itemAligment:self.itemsAligment rightMargin:self.rightMargin upperMargin:self.upperMargin lowerMargin:self.lowerMargin darkening:self.darkening fading:self.fading ergoHeight:self.ergonomicHeight];
519 | layoutSettings.frame= CGRectMake(0.0, 0.0, 240.0, self.settingsView.bounds.size.height);
520 | layoutSettings.delegate = self;
521 |
522 | [self addSettingsModules:@[exampleSetting, layoutSettings, fontSetting, selectedFontSettings, curtainSettings]];
523 | }
524 |
525 |
526 | // adding modules for settings
527 | - (void)addSettingsModules:(NSArray *)modules
528 | {
529 | int count = 0;
530 | CGFloat width = self.settingsView.bounds.size.width;
531 | for (UIView *module in modules) {
532 | if ([module isMemberOfClass:[FontSettingsView class]] || [module isMemberOfClass:[CurtainSettings class]] || [module isMemberOfClass:[LayoutSettingsView class]] || [module isMemberOfClass:[ExamplesSettings class]]) {
533 | module.center = CGPointMake(width/2.0 + count * width, self.scrollView.center.y);
534 | [self.scrollView addSubview:module];
535 | count ++;
536 | }
537 |
538 | }
539 | self.scrollView.contentSize = CGSizeMake(count * self.scrollView.bounds.size.width, self.scrollView.bounds.size.height);
540 | self.pageControl.numberOfPages = count;
541 |
542 | }
543 |
544 |
545 | // removin settings modules
546 | - (void) removeSettingModules
547 | {
548 | for (UIView *module in self.scrollView.subviews) {
549 | [module removeFromSuperview];
550 | }
551 | }
552 |
553 | // opening and closing of settings window
554 | - (void)close
555 | {
556 | [self readAttributes];
557 | if (!self.settingsAreVisible) {
558 | [self initSettingsModules];
559 | [UIView beginAnimations:@"animateSettingsOn" context:NULL];
560 | self.settingsView.frame = CGRectOffset(self.settingsView.frame, 240.0, 0.0);
561 | [UIView commitAnimations];
562 | self.settingsAreVisible = YES;
563 | } else {
564 | [UIView beginAnimations:@"animateSettingsOff" context:NULL];
565 | self.settingsView.frame = CGRectOffset(self.settingsView.frame, -240.0, 0.0);
566 | [UIView commitAnimations];
567 | [self removeSettingModules];
568 | self.settingsAreVisible = NO;
569 | }
570 | }
571 |
572 |
573 | // changing to the previous page of settings
574 | - (void)changeToPreviousPage
575 | {
576 | if (self.pageControl.currentPage !=0) {
577 | self.pageControl.currentPage --;
578 | [self changePage];
579 | }
580 | }
581 |
582 |
583 | // changing to the next page of settings
584 | - (void)changeToNextPage
585 | {
586 | if (self.pageControl.currentPage !=self.pageControl.numberOfPages) {
587 | self.pageControl.currentPage ++;
588 | [self changePage];
589 | }
590 | }
591 |
592 |
593 | // page changing for UIPageControl
594 | - (void)changePage
595 | {
596 | // update the scroll view to the appropriate page
597 | CGRect frame;
598 | frame.origin.x = self.scrollView.frame.size.width * self.pageControl.currentPage;
599 | frame.origin.y = 0;
600 | frame.size = self.scrollView.frame.size;
601 | [self.scrollView scrollRectToVisible:frame animated:YES];
602 |
603 | }
604 |
605 |
606 | // refreshing MJNIndexView
607 | - (void)refresh
608 | {
609 | [self writeAttributes];
610 | [self.indexView refreshIndexItems];
611 |
612 |
613 | }
614 |
615 |
616 |
617 |
618 | # pragma mark TableView datasource methods
619 |
620 | - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
621 | {
622 | return [self.sectionArray count];
623 | }
624 |
625 | - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
626 | {
627 | return [self.sectionArray[section]count];
628 | }
629 |
630 |
631 | - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
632 | {
633 | UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell" forIndexPath:indexPath];
634 | cell.textLabel.font = [UIFont fontWithName:self.indexView.font.fontName size:20.0];
635 | cell.textLabel.text = [NSString stringWithFormat:@" %@",[self categoryNameAtIndexPath:indexPath]];
636 | cell.textLabel.backgroundColor = [UIColor clearColor];
637 | cell.textLabel.textColor = self.tableTextColor;
638 | cell.contentView.backgroundColor = self.tableColor;
639 | cell.selectionStyle = UITableViewCellSelectionStyleGray;
640 |
641 | return cell;
642 | }
643 |
644 |
645 | - (UIView *) tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
646 | {
647 | UITableViewHeaderFooterView *headerView = [tableView dequeueReusableHeaderFooterViewWithIdentifier:@"header"];
648 | headerView.tintColor = self.tableHeaderColor;
649 | headerView.textLabel.textColor = self.tableHeaderTextColor;
650 | headerView.textLabel.font = [UIFont fontWithName:self.indexView.selectedItemFont.fontName size:headerView.textLabel.font.pointSize];
651 | [[headerView textLabel] setText:[NSString stringWithFormat:@" %@",[self firstLetter:section]]];
652 | return headerView;
653 | }
654 |
655 |
656 | #pragma mark building sectionArray for the tableView
657 | - (NSString *)categoryNameAtIndexPath: (NSIndexPath *)path
658 | {
659 | NSArray *currentItems = self.sectionArray[path.section];
660 | NSString *category = currentItems[path.row];
661 | return category;
662 | }
663 |
664 |
665 | - (int) countFirstLettersInArray:(NSArray *)categoryArray
666 | {
667 | NSMutableArray *existingLetters = [NSMutableArray array];
668 | for (NSString *name in categoryArray){
669 | NSString *firstLetterInName = [name substringToIndex:1];
670 | NSCharacterSet *notAllowed = [[NSCharacterSet characterSetWithCharactersInString:@"ABCDEFGHIJKLMNOPQRSTUVWXYZ"] invertedSet];
671 | NSRange range = [firstLetterInName rangeOfCharacterFromSet:notAllowed];
672 |
673 | if (![existingLetters containsObject:firstLetterInName] && range.location == NSNotFound ) {
674 | [existingLetters addObject:firstLetterInName];
675 | self.alphaString = [self.alphaString stringByAppendingString:firstLetterInName];
676 | }
677 | }
678 | return (int)[existingLetters count];
679 | }
680 |
681 |
682 | - (NSArray *) itemsInSection: (NSInteger)section
683 | {
684 | NSPredicate *predicate = [NSPredicate predicateWithFormat:@"SELF beginswith[cd] %@",[self firstLetter:section]];
685 | return [self.crayons filteredArrayUsingPredicate:predicate];
686 | }
687 |
688 |
689 | - (NSString *) firstLetter: (NSInteger) section
690 | {
691 | return [[self.alphaString substringFromIndex:section] substringToIndex:1];
692 | }
693 |
694 |
695 | #pragma mark MJMIndexForTableView datasource methods
696 | - (NSArray *)sectionIndexTitlesForMJNIndexView:(MJNIndexView *)indexView
697 | {
698 | // in example 3 we want to show different index titles
699 | NSString *alpabeth = @"Ằdele Boss Cat Dog Egg Fog George Harry Idle Joke Key Luke Marry New Open Pot Rocket String Table Umbrella Violin Wind Xena Yellow Zyrro";
700 |
701 | NSMutableArray *results = [NSMutableArray array];
702 |
703 | for (int i = 0; i < [self.alphaString length]; i++)
704 | {
705 | NSString *substr = [self.alphaString substringWithRange:NSMakeRange(i,1)];
706 | [results addObject:substr];
707 | }
708 |
709 | if ([self.allExamples[2] boolValue]) return [alpabeth componentsSeparatedByString:@" "];
710 | else {
711 | if ([self.allExamples[3] boolValue]) {
712 | NSMutableArray *lowerCaseResults = [NSMutableArray new];
713 | for (NSString *letter in results) {
714 | [lowerCaseResults addObject:[letter lowercaseString]];
715 | }
716 | results = lowerCaseResults;
717 | }
718 | return results;
719 | }
720 | }
721 |
722 |
723 | - (void)sectionForSectionMJNIndexTitle:(NSString *)title atIndex:(NSInteger)index
724 | {
725 | [self.tableView scrollToRowAtIndexPath:[NSIndexPath indexPathForItem:0 inSection:index] atScrollPosition: UITableViewScrollPositionTop animated:self.getSelectedItemsAfterPanGestureIsFinished];
726 | }
727 |
728 |
729 | #pragma mark settings modules delegate methods
730 | - (void)fontForItem:(UIFont *)font
731 | {
732 | self.font = font;
733 | [self refresh];
734 | }
735 |
736 | - (void)fontForSelectedItem:(UIFont *)font
737 | {
738 | self.selectedItemFont = font;
739 | [self refresh];
740 | }
741 |
742 | - (void)colorForFont:(UIColor *)color
743 | {
744 | self.fontColor = color;
745 | [self refresh];
746 | }
747 |
748 | - (void)colorForSelectedFont:(UIColor *)color
749 | {
750 | self.selectedItemFontColor = color;
751 | [self refresh];
752 | }
753 |
754 | - (void)fadeForCurtain:(CGFloat)fade
755 | {
756 | self.curtainFade = fade;
757 | [self refresh];
758 | }
759 |
760 | - (void)colorForCurtain:(UIColor *)color
761 | {
762 | self.curtainColor = color;
763 | [self refresh];
764 | }
765 |
766 | - (void)marginsForCurtain:(BOOL)margins
767 | {
768 | self.curtainMargins = margins;
769 | [self refresh];
770 | }
771 |
772 | - (void)staysForCurtain:(BOOL)stays
773 | {
774 | self.curtainStays = stays;
775 | [self refresh];
776 | }
777 |
778 | - (void)layoutSettingForIndexItems:(NSDictionary *)settings
779 | {
780 | self.rangeOfDeflection = (int)[settings[@"range"] integerValue];
781 | self.maxItemDeflection = [settings[@"maxDef"] floatValue];
782 | self.itemsAligment = [settings[@"aligment"] integerValue];
783 | self.rightMargin = [settings[@"rightMargin"] floatValue];
784 | self.upperMargin = [settings[@"upperMargin"] floatValue];
785 | self.lowerMargin = [settings[@"lowerMargin"] floatValue];
786 | self.darkening = [settings[@"darkening"] boolValue];
787 | self.fading = [settings[@"fading"] boolValue];
788 | self.ergonomicHeight = [settings[@"ergoHeight"] boolValue];
789 | [self refresh];
790 | }
791 |
792 | - (void)examplesSettingsForDemo:(NSArray *)examples andGettingSelectedAfterPan:(BOOL)after
793 | {
794 | self.allExamples = examples;
795 | if ([examples[0] boolValue]) {
796 | [self firstAttributesForMJNIndexView];
797 | [self firstTableExample];
798 | } else if ([examples[1] boolValue]) {
799 | [self secondAttributesForMJNIndexView];
800 | [self secondTableExample];
801 | } else if ([examples[2] boolValue]) {
802 | [self thirdAttributesForMJNIndexView];
803 | [self thirdTableExample];
804 | } else if ([examples[3] boolValue]) {
805 | [self fourthAttributesForMJNIndexView];
806 | [self fourthTableExample];
807 | } else if ([examples[4] boolValue]) {
808 | [self fifthAttributesForMJNIndexView];
809 | [self fifthTableExample];
810 | }
811 | if (after != self.getSelectedItemsAfterPanGestureIsFinished) {
812 | self.indexView.getSelectedItemsAfterPanGestureIsFinished = after;
813 |
814 | }
815 | [self readAttributes];
816 | [self refresh];
817 |
818 | }
819 |
820 |
821 |
822 | @end
823 |
--------------------------------------------------------------------------------
/MJNIndexForTableView/MJNIndexForTableView-Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleDisplayName
8 | MJN Index
9 | CFBundleExecutable
10 | ${EXECUTABLE_NAME}
11 | CFBundleIcons
12 |
13 | CFBundleIcons~ipad
14 |
15 | CFBundleIdentifier
16 | $(PRODUCT_BUNDLE_IDENTIFIER)
17 | CFBundleInfoDictionaryVersion
18 | 6.0
19 | CFBundleName
20 | MJNIndex
21 | CFBundlePackageType
22 | APPL
23 | CFBundleShortVersionString
24 | 1.0
25 | CFBundleSignature
26 | ????
27 | CFBundleVersion
28 | 1.0
29 | LSRequiresIPhoneOS
30 |
31 | UILaunchStoryboardName
32 | Launch Screen
33 | UIPrerenderedIcon
34 |
35 | UIRequiredDeviceCapabilities
36 |
37 | armv7
38 |
39 | UIRequiresFullScreen
40 |
41 | UIStatusBarHidden
42 |
43 | UISupportedInterfaceOrientations
44 |
45 | UIInterfaceOrientationPortrait
46 |
47 | UISupportedInterfaceOrientations~ipad
48 |
49 | UIInterfaceOrientationPortrait
50 |
51 |
52 |
53 |
--------------------------------------------------------------------------------
/MJNIndexForTableView/MJNIndexForTableView-Prefix.pch:
--------------------------------------------------------------------------------
1 | //
2 | // Prefix header for all source files of the 'MJNIndexForTableView' target in the 'MJNIndexForTableView' project
3 | //
4 |
5 | #import
6 |
7 | #ifndef __IPHONE_5_0
8 | #warning "This project uses features only available in iOS SDK 5.0 and later."
9 | #endif
10 |
11 | #ifdef __OBJC__
12 | #import
13 | #import
14 | #endif
15 |
--------------------------------------------------------------------------------
/MJNIndexForTableView/MJNIndexForTableViewAppDelegate.h:
--------------------------------------------------------------------------------
1 | //
2 | // MJNIndexForTableViewAppDelegate.h
3 | // MJNIndexForTableView
4 | //
5 | // Created by Mateusz Nuckowski on 27/06/13.
6 | // Copyright (c) 2013 Mateusz Nuckowski. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface MJNIndexForTableViewAppDelegate : UIResponder
12 |
13 | @property (strong, nonatomic) UIWindow *window;
14 |
15 | @end
16 |
--------------------------------------------------------------------------------
/MJNIndexForTableView/MJNIndexForTableViewAppDelegate.m:
--------------------------------------------------------------------------------
1 | //
2 | // MJNIndexForTableViewAppDelegate.m
3 | // MJNIndexForTableView
4 | //
5 | // Created by Mateusz Nuckowski on 27/06/13.
6 | // Copyright (c) 2013 Mateusz Nuckowski. All rights reserved.
7 | //
8 |
9 | #import "MJNIndexForTableViewAppDelegate.h"
10 | #import "MJNIndexForTableDemoVC.h"
11 |
12 | @implementation MJNIndexForTableViewAppDelegate
13 |
14 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
15 | {
16 | MJNIndexForTableDemoVC *viewController = [[MJNIndexForTableDemoVC alloc] init];
17 | self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
18 | self.window.rootViewController = viewController;
19 | [self.window makeKeyAndVisible];
20 | return YES;
21 | }
22 |
23 | - (void)applicationWillResignActive:(UIApplication *)application
24 | {
25 | // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
26 | // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
27 | }
28 |
29 | - (void)applicationDidEnterBackground:(UIApplication *)application
30 | {
31 | // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
32 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
33 | }
34 |
35 | - (void)applicationWillEnterForeground:(UIApplication *)application
36 | {
37 | // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
38 | }
39 |
40 | - (void)applicationDidBecomeActive:(UIApplication *)application
41 | {
42 | // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
43 | }
44 |
45 | - (void)applicationWillTerminate:(UIApplication *)application
46 | {
47 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
48 | }
49 |
50 | @end
51 |
--------------------------------------------------------------------------------
/MJNIndexForTableView/MJNIndexView.h:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright (c) 2013, Mateusz Nuckowski.
3 | www.mateusz.nuckowski.com
4 | www.appcowboys.com
5 | All rights reserved.
6 |
7 | This UIControl was inspired by Languages app by Jeremy's Olson Tapity.
8 |
9 | Redistribution and use in source and binary forms, with or without
10 | modification, are permitted provided that the following conditions are met:
11 |
12 | 1. Redistributions of the source code must retain the above copyright notice, this
13 | list of conditions and the following disclaimer.
14 |
15 | 2. Redistributions in binary form must reproduce the above copyright notice,
16 | this list of conditions and the following disclaimer in the documentation
17 | and/or other materials provided with the distribution.
18 |
19 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
23 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 | POSSIBILITY OF SUCH DAMAGE.
30 | */
31 |
32 | #import
33 |
34 | @class MJNIndexView;
35 |
36 | @protocol MJNIndexViewDataSource
37 |
38 | // you have to implement this method to provide this UIControl with NSArray of items you want to display in your index
39 | - (NSArray *)sectionIndexTitlesForMJNIndexView:(MJNIndexView *)indexView;
40 |
41 | // you have to implement this method to get the selected index item
42 | - (void)sectionForSectionMJNIndexTitle:(NSString *)title atIndex:(NSInteger)index;
43 |
44 | @end
45 |
46 |
47 | @interface MJNIndexView : UIControl
48 |
49 | @property (nonatomic, weak) id dataSource;
50 |
51 |
52 | // FOR ALL COLORS USE RGB MODEL - DON'T USE whiteColor, blackColor, grayColor or colorWithWhite, colorWithHue
53 |
54 | // set this to NO if you want to get selected items during the pan (default is YES)
55 | @property (nonatomic, assign) BOOL getSelectedItemsAfterPanGestureIsFinished;
56 |
57 | /* set the font and size of index items (if font size you choose is too large it will be automatically adjusted to the largest possible)
58 | (default is HelveticaNeue 15.0 points)*/
59 | @property (nonatomic, strong) UIFont *font;
60 |
61 | /* set the font of the selected index item (usually you should choose the same font with a bold style and much larger)
62 | (default is the same font as previous one with size 40.0 points) */
63 | @property (nonatomic, strong) UIFont *selectedItemFont;
64 |
65 | // set the color for index items
66 | @property (nonatomic, strong) UIColor *fontColor;
67 |
68 | // set if items in index are going to darken during a pan (default is YES)
69 | @property (nonatomic, assign) BOOL darkening;
70 |
71 | // set if items in index are going ti fade during a pan (default is YES)
72 | @property (nonatomic, assign) BOOL fading;
73 |
74 | // set the color for the selected index item
75 | @property (nonatomic, strong) UIColor *selectedItemFontColor;
76 |
77 | // set index items aligment (NSTextAligmentLeft, NSTextAligmentCenter or NSTextAligmentRight - default is NSTextAligmentCenter)
78 | @property (nonatomic, assign) NSTextAlignment itemsAligment;
79 |
80 | // set the right margin of index items (default is 10.0 points)
81 | @property (nonatomic, assign) CGFloat rightMargin;
82 |
83 | /* set the upper margin of index items (default is 20.0 points)
84 | please remember that margins are set for the largest size of selected item font*/
85 | @property (nonatomic, assign) CGFloat upperMargin;
86 |
87 | // set the lower margin of index items (default is 20.0 points)
88 | // please remember that margins are set for the largest size of selected item font
89 | @property (nonatomic, assign) CGFloat lowerMargin;
90 |
91 | // set the maximum amount for item deflection (default is 75.0 points)
92 | @property (nonatomic,assign) CGFloat maxItemDeflection;
93 |
94 | // set the number of items deflected below and above the selected one (default is 3 items)
95 | @property (nonatomic, assign) int rangeOfDeflection;
96 |
97 | // set the curtain color if you want a curtain to appear (default is none)
98 | @property (nonatomic, strong) UIColor *curtainColor;
99 |
100 | // set the amount of fading for the curtain between 0 to 1 (default is 0.2)
101 | @property (nonatomic, assign) CGFloat curtainFade;
102 |
103 | // set if you need a curtain not to hide completely (default is NO)
104 | @property (nonatomic, assign) BOOL curtainStays;
105 |
106 | // set if you want a curtain to move while panning (default is NO)
107 | @property (nonatomic, assign) BOOL curtainMoves;
108 |
109 | // set if you need a curtain to have the same upper and lower margins (default is NO)
110 | @property (nonatomic, assign) BOOL curtainMargins;
111 |
112 | // set the minimum gap between item (default is 5.0 points)
113 | @property (nonatomic, assign) CGFloat minimumGapBetweenItems;
114 |
115 | // set this property to YES and it will automatically set margins so that gaps between items are set to the minimumItemGap value (default is YES)
116 | @property BOOL ergonomicHeight;
117 |
118 | // set the maximum height for index egronomicHeight - it might be useful for iPad (default is 400.0 ponts)
119 | @property (nonatomic, assign) CGFloat maxValueForErgonomicHeight;
120 |
121 |
122 |
123 | // use this method if you want to change index items or change some properties for layout
124 | - (void)refreshIndexItems;
125 |
126 |
127 | @end
128 |
--------------------------------------------------------------------------------
/MJNIndexForTableView/closeButton.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/matthewfx/MJNIndexView/1a46deaec37b09cee7e81856d75171dcdaa3aea6/MJNIndexForTableView/closeButton.png
--------------------------------------------------------------------------------
/MJNIndexForTableView/closeButton@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/matthewfx/MJNIndexView/1a46deaec37b09cee7e81856d75171dcdaa3aea6/MJNIndexForTableView/closeButton@2x.png
--------------------------------------------------------------------------------
/MJNIndexForTableView/crayons.txt:
--------------------------------------------------------------------------------
1 | Almond #EED9C4
2 | Antique Brass #C88A65
3 | Apricot #FDD5B1
4 | Aquamarine #71D9E2
5 | Asparagus #7BA05B
6 | Atomic Tangerine #FF9966
7 | Banana Mania #FBE7B2
8 | Beaver #926F5B
9 | Bittersweet #FE6F5E
10 | Black #000000
11 | Blizzard Blue #A3E3ED
12 | Blue #0066FF
13 | Blue Bell #9999CC
14 | Blue Green #0095B6
15 | Blue Violet #6456B7
16 | Brick Red #C62D42
17 | Brink Pink #FB607F
18 | Brown #AF593E
19 | Burnt Orange #FF7034
20 | Burnt Sienna #E97451
21 | Cadet Blue #A9B2C3
22 | Canary #FFFF99
23 | Caribbean Green #00CC99
24 | Carnation Pink #FFA6C9
25 | Cerise #DA3287
26 | Cerulean #02A4D3
27 | Chartreuse #FF9966
28 | Chestnut #B94E48
29 | Copper #DA8A67
30 | Cornflower #93CCEA
31 | Cotton Candy #FFB7D5
32 | Cranberry #DB5079
33 | Dandelion #FED85D
34 | Denim #1560BD
35 | Desert Sand #EDC9AF
36 | Eggplant #614051
37 | Electric Lime #CCFF00
38 | Fern #63B76C
39 | Flesh #FFCBA4
40 | Forest Green #5FA777
41 | Fuchsia #C154C1
42 | Fuzzy Wuzzy Brown #C45655
43 | Gold #E6BE8A
44 | Goldenrod #FCD667
45 | Granny Smith Apple #9DE093
46 | Gray #8B8680
47 | Green #01A368
48 | Green Yellow #F1E788
49 | Happy Ever After #6CDA37
50 | Hot Magenta #FF00CC
51 | Inch Worm #B0E313
52 | Indian Red #B94E48
53 | Indigo #4F69C6
54 | Jazzberry Jam #A50B5E
55 | Jungle Green #29AB87
56 | Kelly Green #FFFFFF
57 | Kelp Green #FFFFFF
58 | Key Lime #FFFFFF
59 | Khaki #FFFFFF
60 | Kiwi green #FFFFFF
61 | Kohl #FFFFFF
62 | Kentucky blues grass #FFFFFF
63 | Kinatone #FFFFFF
64 | Laser Lemon #FFFF66
65 | Lavender #FBAED2
66 | Lapis #FFFFFF
67 | Lavender #FFFFFF
68 | Lavender Blush #FFFFFF
69 | Lavender Gray #FFFFFF
70 | Lavender Magenta #FFFFFF
71 | Lawn Green #FFFFFF
72 | Lazuli #FFFFFF
73 | Lemon #FFFFFF
74 | Lemon Chiffon #FFFFFF
75 | Lemon Yellow #FFFFFF
76 | Light Blue #FFFFFF
77 | Light Pink #FFFFFF
78 | Lilac #FFFFFF
79 | Lime #FFFFFF
80 | Lime Green #FFFFFF
81 | Lincoln Green #FFFFFF
82 | Linen #FFFFFF
83 | Lovat #FFFFFF
84 | Macaroni And Cheese #FFB97B
85 | Magenta #F653A6
86 | Magic Mint #AAF0D1
87 | Mahogany #CA3435
88 | Manatee #8D90A1
89 | Mango Tango #E77200
90 | Maroon #C32148
91 | Mauvelous #F091A9
92 | Melon #FEBAAD
93 | Midnight Blue #003366
94 | Mountain Meadow #1AB385
95 | Mulberry #C54B8C
96 | Navy Blue #0066CC
97 | Neon Carrot #FF9933
98 | Olive Green #B5B35C
99 | Orange #FF681F
100 | Orchid #E29CD2
101 | Outer Space #2D383A
102 | Outrageous Orange #FF6037
103 | Pacific Blue #009DC4
104 | Peach #FFCBA4
105 | Periwinkle #C3CDE6
106 | Pig Pink #FDD7E4
107 | Pine Green #01796F
108 | Pink Flamingo #FF66FF
109 | Plum #843179
110 | Prussian Blue #003366
111 | Purple Heart #652DC1
112 | Purple Mountain's Majesty #9678B6
113 | Purple Pizzazz #FF00CC
114 | Radical Red #FF355E
115 | Raw Sienna #D27D46
116 | Razzle Dazzle Rose #FF33CC
117 | Razzmatazz #E30B5C
118 | Red #ED0A3F
119 | Red Orange #FF3F34
120 | Red Violet #BB3385
121 | Robin's Egg Blue #00CCCC
122 | Royal Purple #6B3FA0
123 | Salmon #FF91A4
124 | Scarlet #FD0E35
125 | Screamin' Green #66FF66
126 | Sea Green #93DFB8
127 | Sepia #9E5B40
128 | Shadow #837050
129 | Shamrock #33CC99
130 | Shocking Pink #FF6FFF
131 | Silver #C9C0BB
132 | Sky Blue #76D7EA
133 | Spring Green #ECEBBD
134 | Sunglow #FFCC33
135 | Sunset Orange #FE4C40
136 | Tan #FA9D5A
137 | Tickle Me Pink #FC80A5
138 | Timberwolf #D9D6CF
139 | Torch Red #FD0E35
140 | Tropical Rain Forest #00755E
141 | Tumbleweed #DEA681
142 | Turquoise Blue #6CDAE7
143 | Ultra Green #66FF66
144 | Ultra Orange #FF6037
145 | Ultra Pink #FF6FFF
146 | Ultra Red #FD5B78
147 | Ultra Yellow #FFFF66
148 | Unmellow Yellow #FFFF66
149 | Violet (purple) #8359A3
150 | Violet Red #F7468A
151 | Vivid Tangerine #FF9980
152 | Vivid Violet #803790
153 | Walnut #FFFFFF
154 | Water Blue #FFFFFF
155 | Watermelon #FFFFFF
156 | Wellington #FFFFFF
157 | Wheat #FFFFFF
158 | White #FFFFFF
159 | White Smoke #FFFFFF
160 | Wild Blue Yonder #7A89B8
161 | Wild Strawberry #FF3399
162 | Wild Watermelon #FD5B78
163 | Wine #FFFFFF
164 | Wisteria #C9A0DC
165 | Xanadu #FFFFFF
166 | Xanthian #FFFFFF
167 | Xanthic #FFFFFF
168 | Xaverior #FFFFFF
169 | Xanth #FFFFFF
170 | Yellow #FBE870
171 | Yellow Green #C5E17A
172 | Yellow Orange #FFAE42
173 | Zinc White #FFFFFF
174 | Zaffre #FFFFFF
175 | Zinnwaldite #FFFFFF
176 | Zucchini #FFFFFF
177 | Zillabongium #FFFFFF
178 | Zakittibo #FFFFFF
179 | Zelanga #FFFFFF
180 | Zimbobwayla #FFFFFF
181 | Zing #FFFFFF
182 | Zinnober #FFFFFF
183 | Zymenchlora #FFFFFF
--------------------------------------------------------------------------------
/MJNIndexForTableView/crayons2.txt:
--------------------------------------------------------------------------------
1 | Almond #EED9C4
2 | Antique Brass #C88A65
3 | Apricot #FDD5B1
4 | Aquamarine #71D9E2
5 | Asparagus #7BA05B
6 | Atomic Tangerine #FF9966
7 | Banana Mania #FBE7B2
8 | Beaver #926F5B
9 | Bittersweet #FE6F5E
10 | Black #000000
11 | Blizzard Blue #A3E3ED
12 | Blue #0066FF
13 | Blue Bell #9999CC
14 | Blue Green #0095B6
15 | Blue Violet #6456B7
16 | Brick Red #C62D42
17 | Brink Pink #FB607F
18 | Brown #AF593E
19 | Burnt Orange #FF7034
20 | Burnt Sienna #E97451
21 | Cadet Blue #A9B2C3
22 | Canary #FFFF99
23 | Caribbean Green #00CC99
24 | Carnation Pink #FFA6C9
25 | Cerise #DA3287
26 | Cerulean #02A4D3
27 | Chartreuse #FF9966
28 | Chestnut #B94E48
29 | Copper #DA8A67
30 | Cornflower #93CCEA
31 | Cotton Candy #FFB7D5
32 | Cranberry #DB5079
33 | Dandelion #FED85D
34 | Denim #1560BD
35 | Desert Sand #EDC9AF
36 | Eggplant #614051
37 | Electric Lime #CCFF00
38 | Fern #63B76C
39 | Flesh #FFCBA4
40 | Forest Green #5FA777
41 | Fuchsia #C154C1
42 | Fuzzy Wuzzy Brown #C45655
43 | Gold #E6BE8A
44 | Goldenrod #FCD667
45 | Granny Smith Apple #9DE093
46 | Gray #8B8680
47 | Green #01A368
48 | Green Yellow #F1E788
49 | Happy Ever After #6CDA37
50 | Hot Magenta #FF00CC
51 | Inch Worm #B0E313
52 | Indian Red #B94E48
53 | Indigo #4F69C6
54 | Jazzberry Jam #A50B5E
55 | Jungle Green #29AB87
56 | Kelly Green #FFFFFF
57 | Kelp Green #FFFFFF
58 | Key Lime #FFFFFF
59 | Khaki #FFFFFF
60 | Kiwi green #FFFFFF
61 | Kohl #FFFFFF
62 | Kentucky blues grass #FFFFFF
63 | Kinatone #FFFFFF
64 | Laser Lemon #FFFF66
65 | Lavender #FBAED2
66 | Lapis #FFFFFF
67 | Lavender #FFFFFF
68 | Lavender Blush #FFFFFF
69 | Lavender Gray #FFFFFF
70 | Lavender Magenta #FFFFFF
71 | Lawn Green #FFFFFF
72 | Lazuli #FFFFFF
73 | Lemon #FFFFFF
74 | Lemon Chiffon #FFFFFF
75 | Lemon Yellow #FFFFFF
76 | Light Blue #FFFFFF
77 | Light Pink #FFFFFF
78 | Lilac #FFFFFF
79 | Lime #FFFFFF
80 | Lime Green #FFFFFF
81 | Lincoln Green #FFFFFF
82 | Linen #FFFFFF
83 | Lovat #FFFFFF
--------------------------------------------------------------------------------
/MJNIndexForTableView/en.lproj/InfoPlist.strings:
--------------------------------------------------------------------------------
1 | /* Localized versions of Info.plist keys */
2 |
3 |
--------------------------------------------------------------------------------
/MJNIndexForTableView/main.m:
--------------------------------------------------------------------------------
1 | //
2 | // main.m
3 | // MJNIndexForTableView
4 | //
5 | // Created by Mateusz Nuckowski on 27/06/13.
6 | // Copyright (c) 2013 Mateusz Nuckowski. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | #import "MJNIndexForTableViewAppDelegate.h"
12 |
13 | int main(int argc, char *argv[])
14 | {
15 | @autoreleasepool {
16 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([MJNIndexForTableViewAppDelegate class]));
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/MJNIndexForTableView/nextButton.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/matthewfx/MJNIndexView/1a46deaec37b09cee7e81856d75171dcdaa3aea6/MJNIndexForTableView/nextButton.png
--------------------------------------------------------------------------------
/MJNIndexForTableView/nextButton@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/matthewfx/MJNIndexView/1a46deaec37b09cee7e81856d75171dcdaa3aea6/MJNIndexForTableView/nextButton@2x.png
--------------------------------------------------------------------------------
/MJNIndexForTableView/prevButton.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/matthewfx/MJNIndexView/1a46deaec37b09cee7e81856d75171dcdaa3aea6/MJNIndexForTableView/prevButton.png
--------------------------------------------------------------------------------
/MJNIndexForTableView/prevButton@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/matthewfx/MJNIndexView/1a46deaec37b09cee7e81856d75171dcdaa3aea6/MJNIndexForTableView/prevButton@2x.png
--------------------------------------------------------------------------------
/MJNIndexForTableView/settingsButton.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/matthewfx/MJNIndexView/1a46deaec37b09cee7e81856d75171dcdaa3aea6/MJNIndexForTableView/settingsButton.png
--------------------------------------------------------------------------------
/MJNIndexForTableView/settingsButton@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/matthewfx/MJNIndexView/1a46deaec37b09cee7e81856d75171dcdaa3aea6/MJNIndexForTableView/settingsButton@2x.png
--------------------------------------------------------------------------------
/MJNIndexView readMe.rtf:
--------------------------------------------------------------------------------
1 | {\rtf1\ansi\ansicpg1252\cocoartf1187\cocoasubrtf390
2 | {\fonttbl\f0\fswiss\fcharset0 Helvetica;\f1\froman\fcharset0 TimesNewRomanPSMT;\f2\fmodern\fcharset0 CourierNewPSMT;
3 | \f3\fnil\fcharset0 LucidaGrande;}
4 | {\colortbl;\red255\green255\blue255;\red170\green13\blue145;\red63\green110\blue116;\red92\green38\blue153;
5 | \red46\green13\blue110;\red0\green116\blue0;\red196\green26\blue22;\red28\green0\blue207;}
6 | {\*\listtable{\list\listtemplateid1\listhybrid{\listlevel\levelnfc23\levelnfcn23\leveljc0\leveljcn0\levelfollow0\levelstartat1\levelspace360\levelindent0{\*\levelmarker \{disc\}}{\leveltext\leveltemplateid1\'01\uc0\u8226 ;}{\levelnumbers;}\fi-360\li720\lin720 }{\listname ;}\listid1}}
7 | {\*\listoverridetable{\listoverride\listid1\listoverridecount0\ls1}}
8 | \paperw11900\paperh16840\margl1134\margr1134\margb1134\margt1134\vieww20520\viewh13940\viewkind0
9 | \deftab709
10 | \pard\pardeftab709
11 |
12 | \f0\b\fs30 \cf0 MJNIndexView
13 | \f1\b0\fs24 \
14 | \pard\pardeftab709
15 |
16 | \f0 \cf0 \
17 | \pard\pardeftab709\sl360\slmult1
18 | \cf0 MJNIndexView is an UIControl which displays an alternative index for UITableView. I wanted to mimic the index designed by Jeremy Olson's Tapity for their Languages app. I think their idea of implementing index is brilliant and it is one of the best examples of great UX. I hope more apps are going to use similar indices instead of the generic ones.
19 | \f1 \
20 | \pard\pardeftab709
21 | \cf0 \
22 | \pard\pardeftab709
23 |
24 | \f0\b\fs26 \cf0 Example code:
25 | \f1\b0\fs24 \
26 | \
27 | \pard\pardeftab709
28 |
29 | \f2\fs20 \cf2 @interface\cf0 \cf3 MJNIndexTestViewController\cf0 () <\cf3 MJNIndexViewDataSource\cf0 >
30 | \f1\fs24 \
31 | \pard\pardeftab709
32 |
33 | \f2\fs20 \cf0 \
34 | \pard\tx529\pardeftab709
35 | \cf2 @property\cf0 (\cf2 nonatomic\cf0 , \cf2 strong\cf0 ) \cf3 MJNIndexView\cf0 *indexView;
36 | \f1\fs24 \
37 |
38 | \f2\fs20 \cf2 @property\cf0 (\cf2 nonatomic\cf0 , \cf2 strong\cf0 ) \cf4 NSMutableArray\cf0 *sectionArray;
39 | \f1\fs24 \
40 |
41 | \f2\fs20 \cf2 @property\cf0 (\cf2 nonatomic\cf0 , \cf2 strong\cf0 ) \cf4 UITableView\cf0 *tableView;
42 | \f1\fs24 \
43 | \pard\tx529\pardeftab709
44 |
45 | \f2\fs20 \cf0 \
46 | \pard\tx529\pardeftab709
47 | \cf2 @end
48 | \f1\fs24 \cf0 \
49 | \pard\tx529\pardeftab709
50 |
51 | \f2\fs20 \cf0 \
52 | \pard\tx529\pardeftab709
53 | \cf2 @implementation\cf0 MJNIndexTestViewController
54 | \f1\fs24 \
55 | \pard\tx529\pardeftab709
56 |
57 | \f2\fs20 \cf0 \
58 | - (\cf2 void\cf0 )viewDidLoad
59 | \f1\fs24 \
60 |
61 | \f2\fs20 \{
62 | \f1\fs24 \
63 |
64 | \f2\fs20 [\cf2 super\cf0 \cf5 viewDidLoad\cf0 ];
65 | \f1\fs24 \
66 |
67 | \f2\fs20 \
68 | \cf6 // initialise tableView
69 | \f1\fs24 \cf0 \
70 | \pard\tx529\pardeftab709
71 |
72 | \f2\fs20 \cf6 \cf2 self\cf0 .\cf3 tableView\cf0 = [[\cf4 UITableView\cf0 \cf5 alloc\cf0 ] \cf5 initWithFrame\cf0 :\cf2 self\cf0 .\cf4 view\cf0 .\cf4 bounds\cf0 ] [\cf2 self\cf0 .\cf3 tableView\cf0 \cf5 registerClass\cf0 :[\cf4 UITableViewCell
73 | \f1\fs24 \cf0 \
74 | \pard\tx529\pardeftab709
75 |
76 | \f2\fs20 \cf0 \cf5 class\cf0 ]\cf5 forCellReuseIdentifier\cf0 :\cf7 @"cell"\cf0 ];
77 | \f1\fs24 \
78 |
79 | \f2\fs20 \cf2 self\cf0 .\cf3 tableView\cf0 .\cf4 dataSource\cf0 = \cf2 self\cf0 ;
80 | \f1\fs24 \
81 |
82 | \f2\fs20 \cf2 self\cf0 .\cf3 tableView\cf0 .\cf4 delegate\cf0 = \cf2 self\cf0 ;
83 | \f1\fs24 \
84 |
85 | \f2\fs20 \cf2 self\cf0 .\cf3 tableView\cf0 .\cf4 showsVerticalScrollIndicator\cf0 = \cf2 NO\cf0 ;
86 | \f1\fs24 \
87 |
88 | \f2\fs20 [\cf2 self\cf0 .\cf4 view\cf0 \cf5 addSubview\cf0 :\cf2 self\cf0 .\cf3 tableView\cf0 ];
89 | \f1\fs24 \
90 |
91 | \f2\fs20 \
92 | \pard\tx529\pardeftab709
93 | \cf6 // initialise MJNIndexView
94 | \f1\fs24 \cf0 \
95 |
96 | \f2\fs20 \cf6 \cf2 self\cf0 .\cf3 indexView\cf0 = [[\cf3 MJNIndexView\cf0 \cf5 alloc\cf0 ]\cf5 initWithFrame\cf0 :\cf2 self\cf0 .\cf4 view\cf0 .\cf4 bounds\cf0 ];
97 | \f1\fs24 \
98 | \pard\tx529\pardeftab709
99 |
100 | \f2\fs20 \cf0 \cf2 self\cf0 .\cf3 indexView\cf0 .\cf3 dataSource\cf0 = \cf2 self\cf0 ;
101 | \f1\fs24 \
102 |
103 | \f2\fs20 \cf2 self\cf0 .\cf3 indexView\cf0 .\cf3 fontColor\cf0 = [\cf4 UIColor\cf0 \cf5 blueColor\cf0 ];
104 | \f1\fs24 \
105 |
106 | \f2\fs20 [\cf2 self\cf0 .\cf4 view\cf0 \cf5 addSubview\cf0 :\cf2 self\cf0 .\cf3 indexView\cf0 ];
107 | \f1\fs24 \
108 |
109 | \f2\fs20 \}
110 | \f1\fs24 \
111 |
112 | \f2\fs20 \
113 | \pard\tx529\pardeftab709
114 | \cf6 // two methods needed for MJNINdexView protocol
115 | \f1\fs24 \cf0 \
116 | \pard\tx529\pardeftab709
117 |
118 | \f2\fs20 \cf0 - (\cf4 NSArray\cf0 *)sectionIndexTitlesForMJNIndexView:(\cf3 MJNIndexView\cf0 *)indexView
119 | \f1\fs24 \
120 |
121 | \f2\fs20 \{
122 | \f1\fs24 \
123 |
124 | \f2\fs20 \cf2 return\cf0 sectionArray;
125 | \f1\fs24 \
126 |
127 | \f2\fs20 \}
128 | \f1\fs24 \
129 |
130 | \f2\fs20 \
131 | - (\cf2 void\cf0 )sectionForSectionMJNIndexTitle:(\cf4 NSString\cf0 *)title atIndex:(\cf4 NSInteger\cf0 )index;
132 | \f1\fs24 \
133 |
134 | \f2\fs20 \{
135 | \f1\fs24 \
136 |
137 | \f2\fs20 [\cf2 self\cf0 .\cf3 tableView\cf0 \cf5 scrollToRowAtIndexPath\cf0 :[\cf4 NSIndexPath\cf0 \cf5 indexPathForItem\cf0 :\cf8 0\cf0 \cf5 inSection\cf0 :index] \cf5 atScrollPosition\cf0 : \cf5 UITableViewScrollPositionTop\cf0 \cf5 animated\cf0 :\cf2 NO\cf0 ];
138 | \f1\fs24 \
139 |
140 | \f2\fs20 \}
141 | \f1\fs24 \
142 |
143 | \f2\fs20 .
144 | \f1\fs24 \
145 |
146 | \f2\fs20 .
147 | \f1\fs24 \
148 |
149 | \f2\fs20 .
150 | \f1\fs24 \
151 | \pard\tx529\pardeftab709
152 |
153 | \f2\fs20 \cf2 @end
154 | \f1\fs24 \cf0 \
155 | \pard\pardeftab709
156 | \cf0 \
157 | \pard\pardeftab709
158 |
159 | \f0\b\fs26 \cf0 Usage
160 | \f1 :
161 | \b0\fs24 \
162 | \
163 | \pard\pardeftab709\sl360\slmult1
164 |
165 | \f0 \cf0 Only two files are required for using MJNIndexView:
166 | \f2 MJNindexView.h
167 | \f0 &
168 | \f2 MJNIndexView.m
169 | \f0 .
170 | \f1 \
171 |
172 | \f0 Copy both of them into your Xcode Project.
173 | \f1 \
174 | \pard\pardeftab709\sl360\slmult1
175 |
176 | \f0\i\b \cf0 Make sure to include QuartzCore framework in your target.
177 | \f1\i0\b0 \
178 | \pard\pardeftab709\sl360\slmult1
179 |
180 | \f0 \cf0 \
181 | Your UIViewController must implement MJNIndexViewDataSource protocol methods. The first one of them is needed to provide the index with all section titles. The second one is needed to provide UIViewController with a title or index number selected by a user.
182 | \f1 \
183 |
184 | \f0 \
185 | You can customize the look and behaviour of MJNIndex by tweaking more than 20 parameters. You can experiment with the most of them in the demo app.
186 | \f1 \
187 |
188 | \f0 \
189 | If you want to change items in the index or most of its parameters after the MJNIndexView was added to the superView you should use the method \'96 (void)refreshIndexItems to recalculate every item position, size etc.
190 | \f1 \
191 | \pard\pardeftab709
192 | \cf0 \
193 | \pard\pardeftab709
194 |
195 | \f0\b\fs26 \cf0 To do:
196 | \f1\b0\fs24 \
197 |
198 | \f0\b\fs26 \
199 | \pard\pardeftab709\li720\fi-360\ri-6\sl360\slmult1
200 | \ls1\ilvl0
201 | \f3\b0\fs24 \cf0 \'95
202 | \f0 Improve a curtain fade (it could behave strange when you use very large value for the right margin).
203 | \f1 \
204 | \ls1\ilvl0
205 | \f3 \'95
206 | \f0 Cocoapod
207 | \f1 \
208 | \pard\pardeftab709
209 | \cf0 \
210 | \pard\pardeftab709
211 |
212 | \f0\b\fs26 \cf0 Credits:
213 | \f1\b0\fs24 \
214 |
215 | \f0\b\fs26 \
216 | \pard\pardeftab709
217 |
218 | \b0\fs24 \cf0 If you use this control in your app, please add some credits.
219 | \f1 \
220 | \
221 | \
222 | }
--------------------------------------------------------------------------------
/MJNIndexView.h:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright (c) 2013, Mateusz Nuckowski.
3 | www.mateusz.nuckowski.com
4 | www.appcowboys.com
5 | All rights reserved.
6 |
7 | This UIControl was inspired by Languages app by Jeremy's Olson Tapity.
8 |
9 | Redistribution and use in source and binary forms, with or without
10 | modification, are permitted provided that the following conditions are met:
11 |
12 | 1. Redistributions of the source code must retain the above copyright notice, this
13 | list of conditions and the following disclaimer.
14 |
15 | 2. Redistributions in binary form must reproduce the above copyright notice,
16 | this list of conditions and the following disclaimer in the documentation
17 | and/or other materials provided with the distribution.
18 |
19 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
23 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 | POSSIBILITY OF SUCH DAMAGE.
30 | */
31 |
32 | #import
33 |
34 | @class MJNIndexView;
35 |
36 | @protocol MJNIndexViewDataSource
37 |
38 | // you have to implement this method to provide this UIControl with NSArray of items you want to display in your index
39 | - (NSArray *)sectionIndexTitlesForMJNIndexView:(MJNIndexView *)indexView;
40 |
41 | // you have to implement this method to get the selected index item
42 | - (void)sectionForSectionMJNIndexTitle:(NSString *)title atIndex:(NSInteger)index;
43 |
44 | @end
45 |
46 |
47 | @interface MJNIndexView : UIControl
48 |
49 | @property (nonatomic, weak) id dataSource;
50 |
51 |
52 | // FOR ALL COLORS USE RGB MODEL - DON'T USE whiteColor, blackColor, grayColor or colorWithWhite, colorWithHue
53 |
54 | // set this to NO if you want to get selected items during the pan (default is YES)
55 | @property (nonatomic, assign) BOOL getSelectedItemsAfterPanGestureIsFinished;
56 |
57 | /* set the font and size of index items (if font size you choose is too large it will be automatically adjusted to the largest possible)
58 | (default is HelveticaNeue 15.0 points)*/
59 | @property (nonatomic, strong) UIFont *font;
60 |
61 | /* set the font of the selected index item (usually you should choose the same font with a bold style and much larger)
62 | (default is the same font as previous one with size 40.0 points) */
63 | @property (nonatomic, strong) UIFont *selectedItemFont;
64 |
65 | // set the color for index items
66 | @property (nonatomic, strong) UIColor *fontColor;
67 |
68 | // set if items in index are going to darken during a pan (default is YES)
69 | @property (nonatomic, assign) BOOL darkening;
70 |
71 | // set if items in index are going ti fade during a pan (default is YES)
72 | @property (nonatomic, assign) BOOL fading;
73 |
74 | // set the color for the selected index item
75 | @property (nonatomic, strong) UIColor *selectedItemFontColor;
76 |
77 | // set index items aligment (NSTextAligmentLeft, NSTextAligmentCenter or NSTextAligmentRight - default is NSTextAligmentCenter)
78 | @property (nonatomic, assign) NSTextAlignment itemsAligment;
79 |
80 | // set the right margin of index items (default is 10.0 points)
81 | @property (nonatomic, assign) CGFloat rightMargin;
82 |
83 | /* set the upper margin of index items (default is 20.0 points)
84 | please remember that margins are set for the largest size of selected item font*/
85 | @property (nonatomic, assign) CGFloat upperMargin;
86 |
87 | // set the lower margin of index items (default is 20.0 points)
88 | // please remember that margins are set for the largest size of selected item font
89 | @property (nonatomic, assign) CGFloat lowerMargin;
90 |
91 | // set the maximum amount for item deflection (default is 75.0 points)
92 | @property (nonatomic,assign) CGFloat maxItemDeflection;
93 |
94 | // set the number of items deflected below and above the selected one (default is 3 items)
95 | @property (nonatomic, assign) int rangeOfDeflection;
96 |
97 | // set the curtain color if you want a curtain to appear (default is none)
98 | @property (nonatomic, strong) UIColor *curtainColor;
99 |
100 | // set the amount of fading for the curtain between 0 to 1 (default is 0.2)
101 | @property (nonatomic, assign) CGFloat curtainFade;
102 |
103 | // set if you need a curtain not to hide completely (default is NO)
104 | @property (nonatomic, assign) BOOL curtainStays;
105 |
106 | // set if you want a curtain to move while panning (default is NO)
107 | @property (nonatomic, assign) BOOL curtainMoves;
108 |
109 | // set if you need a curtain to have the same upper and lower margins (default is NO)
110 | @property (nonatomic, assign) BOOL curtainMargins;
111 |
112 | // set the minimum gap between item (default is 5.0 points)
113 | @property (nonatomic, assign) CGFloat minimumGapBetweenItems;
114 |
115 | // set this property to YES and it will automatically set margins so that gaps between items are set to the minimumItemGap value (default is YES)
116 | @property BOOL ergonomicHeight;
117 |
118 | // set the maximum height for index egronomicHeight - it might be useful for iPad (default is 400.0 ponts)
119 | @property (nonatomic, assign) CGFloat maxValueForErgonomicHeight;
120 |
121 |
122 |
123 | // use this method if you want to change index items or change some properties for layout
124 | - (void)refreshIndexItems;
125 |
126 |
127 | @end
128 |
--------------------------------------------------------------------------------
/MJNIndexView.podspec:
--------------------------------------------------------------------------------
1 | #
2 | # Be sure to run `pod lib lint MJNIndexView.podspec' to ensure this is a
3 | # valid spec before submitting.
4 | #
5 | # Any lines starting with a # are optional, but their use is encouraged
6 | # To learn more about a Podspec see https://guides.cocoapods.org/syntax/podspec.html
7 | #
8 |
9 | Pod::Spec.new do |s|
10 | s.name = 'MJNIndexView'
11 | s.version = '1.1.1'
12 | s.summary = 'MJNIndexView is a highly customizable index for UITableView'
13 |
14 | # This description is used to generate tags and improve search results.
15 | # * Think: What does it do? Why did you write it? What is the focus?
16 | # * Try to keep it short, snappy and to the point.
17 | # * Write the description between the DESC delimiters below.
18 | # * Finally, don't worry about the indent, CocoaPods strips it!
19 |
20 | s.description = <<-DESC
21 | MJNIndexView is a highly customizable UIControl which displays an alternative index for UITableView.\n I wanted to mimic the index designed by Jeremy Olson's Tapity for their Languages app.\n I think their idea of implementing index is brilliant and it is one of the best examples of great UX.\n I hope more apps are going to use similar indices instead of the generic ones.\n
22 | DESC
23 |
24 | s.homepage = 'https://github.com/matthewfx/MJNIndexView'
25 | # s.screenshots = 'www.example.com/screenshots_1', 'www.example.com/screenshots_2'
26 | s.license = { :type => 'MIT', :file => 'LICENSE.md' }
27 | s.author = { 'matthewfx' => 'mat@nuckowski.com' }
28 | s.source = { :git => 'https://github.com/matthewfx/MJNIndexView.git', :tag => '1.1.1'}
29 | # s.social_media_url = 'https://twitter.com/'
30 |
31 | s.ios.deployment_target = '8.0'
32 |
33 | s.source_files = 'MJNIndexView.{h,m}'
34 | s.frameworks = 'QuartzCore', 'CoreGraphics'
35 |
36 | # s.resource_bundles = {
37 | # 'MJNIndexView' => ['MJNIndexView/Assets/*.png']
38 | # }
39 |
40 | # s.public_header_files = 'Pod/Classes/**/*.h'
41 | # s.frameworks = 'UIKit', 'MapKit'
42 | # s.dependency 'AFNetworking', '~> 2.3'
43 | end
44 |
--------------------------------------------------------------------------------
/MJNIndexView01.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/matthewfx/MJNIndexView/1a46deaec37b09cee7e81856d75171dcdaa3aea6/MJNIndexView01.png
--------------------------------------------------------------------------------
/MJNIndexView02.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/matthewfx/MJNIndexView/1a46deaec37b09cee7e81856d75171dcdaa3aea6/MJNIndexView02.png
--------------------------------------------------------------------------------
/MJNIndexView03.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/matthewfx/MJNIndexView/1a46deaec37b09cee7e81856d75171dcdaa3aea6/MJNIndexView03.png
--------------------------------------------------------------------------------
/MJNIndexView04.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/matthewfx/MJNIndexView/1a46deaec37b09cee7e81856d75171dcdaa3aea6/MJNIndexView04.png
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | iOS - MJNIndexView
2 | ==================
3 |
4 | MJNIndexView is a highly customizable UIControl which displays an alternative index for UITableView. I wanted to mimic the index designed by Jeremy Olson's Tapity for their Languages app. I think their idea of implementing index is brilliant and it is one of the best examples of great UX. I hope more apps are going to use similar indices instead of the generic ones.
5 |
6 |
7 | 
8 | 
9 | 
10 | 
11 |
12 | ### Youtube video
13 |
14 | [](http://www.youtube.com/watch?v=uV3bkPkC-GQ)
15 |
16 | ### Example Code
17 |
18 | ```objective-c
19 |
20 | @interface MJNIndexTestViewController ()
21 |
22 | @property (nonatomic, strong) MJNIndexView *indexView;
23 | @property (nonatomic, strong) NSMutableArray *sectionArray;
24 | @property (nonatomic, strong) UITableView *tableView;
25 |
26 | @end
27 |
28 | @implementation MJNIndexTestViewController
29 |
30 | - (void)viewDidLoad
31 | {
32 | [super viewDidLoad];
33 |
34 | // initialise tableView
35 | self.tableView = [[UITableView alloc] initWithFrame:self.view.bounds] [self.tableView registerClass:[UITableViewCell
36 | class]forCellReuseIdentifier:@"cell"];
37 | self.tableView.dataSource = self;
38 | self.tableView.delegate = self;
39 | self.tableView.showsVerticalScrollIndicator = NO;
40 | [self.view addSubview:self.tableView];
41 |
42 | // initialise MJNIndexView
43 | self.indexView = [[MJNIndexView alloc]initWithFrame:self.view.bounds];
44 | self.indexView.dataSource = self;
45 | self.indexView.fontColor = [UIColor blueColor];
46 | [self.view addSubview:self.indexView];
47 | }
48 |
49 | // two methods needed for MJNINdexView protocol
50 | - (NSArray *)sectionIndexTitlesForMJNIndexView:(MJNIndexView *)indexView
51 | {
52 | return sectionArray;
53 | }
54 |
55 | - (void)sectionForSectionMJNIndexTitle:(NSString *)title atIndex:(NSInteger)index;
56 | {
57 | [self.tableView scrollToRowAtIndexPath:[NSIndexPath indexPathForItem:0 inSection:index] atScrollPosition: UITableViewScrollPositionTop animated:NO];
58 | }
59 | .
60 | .
61 | .
62 | @end
63 | ```
64 |
65 | ### Usage
66 |
67 | Only two files are required for using MJNIndexView: `MJNindexView.h` & `MJNIndexView.m`.
68 | Copy both of them into your Xcode Project.
69 | Make sure to include QuartzCore framework in your target.
70 |
71 | Your UIViewController must implement MJNIndexViewDataSource protocol methods. The first one of them is needed to provide the index with all section titles. The second one is needed to provide UIViewController with a title or index number selected by a user.
72 |
73 | You can customize the look and behaviour of MJNIndex by tweaking more than 20 parameters. You can experiment with the most of them in the demo app.
74 |
75 | If you want to change items in the index or most of its parameters after the MJNIndexView was added to the superView you should use the method `– (void)refreshIndexItems` to recalculate every item position, size etc.
76 |
77 | ### To do
78 |
79 | • Improve a curtain fade (it could behave strange when you use very large value for the right margin).
80 |
81 | • Improve performance on older devices
82 |
83 | • Cocoapod
84 |
85 | ### Credits
86 |
87 | If you use this control in your app, please add some credits.
88 |
89 | ## License
90 |
91 | ### MIT License
92 |
93 | Copyright (c) 2013 Mateusz Nuckowski (http://mateusz.nuckowski.com)
94 |
95 | Permission is hereby granted, free of charge, to any person obtaining a copy
96 | of this software and associated documentation files (the "Software"), to deal
97 | in the Software without restriction, including without limitation the rights
98 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
99 | copies of the Software, and to permit persons to whom the Software is
100 | furnished to do so, subject to the following conditions:
101 |
102 | The above copyright notice and this permission notice shall be included in
103 | all copies or substantial portions of the Software.
104 |
105 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
106 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
107 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
108 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
109 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
110 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
111 | THE SOFTWARE.
112 |
113 |
--------------------------------------------------------------------------------
/_Pods.xcodeproj:
--------------------------------------------------------------------------------
1 | Example/Pods/Pods.xcodeproj
--------------------------------------------------------------------------------