├── LICENSE
├── README.md
├── YKPageView.xcodeproj
├── project.pbxproj
├── project.xcworkspace
│ ├── contents.xcworkspacedata
│ ├── xcshareddata
│ │ └── YKPageView.xccheckout
│ └── xcuserdata
│ │ └── Mark.xcuserdatad
│ │ ├── UserInterfaceState.xcuserstate
│ │ └── WorkspaceSettings.xcsettings
└── xcuserdata
│ └── Mark.xcuserdatad
│ ├── xcdebugger
│ └── Breakpoints_v2.xcbkptlist
│ └── xcschemes
│ ├── YKPageView.xcscheme
│ └── xcschememanagement.plist
├── YKPageView
├── AppDelegate.h
├── AppDelegate.m
├── Base.lproj
│ ├── LaunchScreen.xib
│ └── Main.storyboard
├── Images.xcassets
│ └── AppIcon.appiconset
│ │ └── Contents.json
├── Info.plist
├── MenuView
│ ├── YKFooldView.h
│ ├── YKFooldView.m
│ ├── YKMenuItem.h
│ ├── YKMenuItem.m
│ ├── YKMenuView.h
│ ├── YKMenuView.m
│ ├── YKPageCell.h
│ ├── YKPageCell.m
│ ├── YKPageView.h
│ ├── YKPageView.m
│ ├── YKProgressView.h
│ └── YKProgressView.m
├── ScreenShot
│ ├── CosChat.gif
│ └── ScreenShot.gif
├── UIColor+Random.h
├── UIColor+Random.m
├── ViewController.h
├── ViewController.m
└── main.m
└── YKPageViewTests
├── Info.plist
└── YKPageViewTests.m
/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2015 Wang Ming
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # YKPageView
2 |
3 | ## Description
4 | [](https://developer.apple.com/iphone/index.action)
6 | [](http://mit-license.org)
8 |
9 | 新做了一个由控制器作为Cell的版本,可以更加方便的实现一些功能,控制器版请戳:
10 | https://github.com/wangmchn/WMPageController
11 |
12 |
13 | ## How to use
14 | * `#import "YKPageView"`, 使用方法类似 `UITableView`
15 | * 实现相应的 `delegate` 和 `dataSource` 方法即可, 具体可参见 `Demo`;
16 |
17 | ## Final
18 | 效果图如下:
19 |
20 |
21 |
22 | 你当然也可以就将它这么放到你的项目中:
23 |
24 |
25 |
--------------------------------------------------------------------------------
/YKPageView.xcodeproj/project.pbxproj:
--------------------------------------------------------------------------------
1 | // !$*UTF8*$!
2 | {
3 | archiveVersion = 1;
4 | classes = {
5 | };
6 | objectVersion = 46;
7 | objects = {
8 |
9 | /* Begin PBXBuildFile section */
10 | 4D0FDB721B1A029D00F02AE3 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 4D0FDB711B1A029D00F02AE3 /* main.m */; };
11 | 4D0FDB751B1A029D00F02AE3 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 4D0FDB741B1A029D00F02AE3 /* AppDelegate.m */; };
12 | 4D0FDB781B1A029D00F02AE3 /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 4D0FDB771B1A029D00F02AE3 /* ViewController.m */; };
13 | 4D0FDB7B1B1A029D00F02AE3 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 4D0FDB791B1A029D00F02AE3 /* Main.storyboard */; };
14 | 4D0FDB7D1B1A029D00F02AE3 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 4D0FDB7C1B1A029D00F02AE3 /* Images.xcassets */; };
15 | 4D0FDB801B1A029D00F02AE3 /* LaunchScreen.xib in Resources */ = {isa = PBXBuildFile; fileRef = 4D0FDB7E1B1A029D00F02AE3 /* LaunchScreen.xib */; };
16 | 4D0FDB8C1B1A029D00F02AE3 /* YKPageViewTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 4D0FDB8B1B1A029D00F02AE3 /* YKPageViewTests.m */; };
17 | 4D0FDBA01B1A02BD00F02AE3 /* YKPageCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 4D0FDB9B1B1A02BD00F02AE3 /* YKPageCell.m */; };
18 | 4D0FDBA11B1A02BD00F02AE3 /* YKPageView.m in Sources */ = {isa = PBXBuildFile; fileRef = 4D0FDB9D1B1A02BD00F02AE3 /* YKPageView.m */; };
19 | 4D0FDBA51B1A02E300F02AE3 /* UIColor+Random.m in Sources */ = {isa = PBXBuildFile; fileRef = 4D0FDBA41B1A02E300F02AE3 /* UIColor+Random.m */; };
20 | 4DF26ED71BAAF1FC0025AA06 /* YKFooldView.m in Sources */ = {isa = PBXBuildFile; fileRef = 4DF26ED41BAAF1FC0025AA06 /* YKFooldView.m */; };
21 | 4DF26ED81BAAF1FC0025AA06 /* YKMenuItem.m in Sources */ = {isa = PBXBuildFile; fileRef = 4DF26ED61BAAF1FC0025AA06 /* YKMenuItem.m */; };
22 | 4DF26EDB1BAAF31A0025AA06 /* YKMenuView.m in Sources */ = {isa = PBXBuildFile; fileRef = 4DF26EDA1BAAF31A0025AA06 /* YKMenuView.m */; };
23 | 4DF26EDE1BAAF4590025AA06 /* YKProgressView.m in Sources */ = {isa = PBXBuildFile; fileRef = 4DF26EDD1BAAF4590025AA06 /* YKProgressView.m */; };
24 | /* End PBXBuildFile section */
25 |
26 | /* Begin PBXContainerItemProxy section */
27 | 4D0FDB861B1A029D00F02AE3 /* PBXContainerItemProxy */ = {
28 | isa = PBXContainerItemProxy;
29 | containerPortal = 4D0FDB641B1A029D00F02AE3 /* Project object */;
30 | proxyType = 1;
31 | remoteGlobalIDString = 4D0FDB6B1B1A029D00F02AE3;
32 | remoteInfo = YKPageView;
33 | };
34 | /* End PBXContainerItemProxy section */
35 |
36 | /* Begin PBXFileReference section */
37 | 4D0FDB6C1B1A029D00F02AE3 /* YKPageView.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = YKPageView.app; sourceTree = BUILT_PRODUCTS_DIR; };
38 | 4D0FDB701B1A029D00F02AE3 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; };
39 | 4D0FDB711B1A029D00F02AE3 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; };
40 | 4D0FDB731B1A029D00F02AE3 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; };
41 | 4D0FDB741B1A029D00F02AE3 /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; };
42 | 4D0FDB761B1A029D00F02AE3 /* ViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = ""; };
43 | 4D0FDB771B1A029D00F02AE3 /* ViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; lineEnding = 0; path = ViewController.m; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.objc; };
44 | 4D0FDB7A1B1A029D00F02AE3 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; };
45 | 4D0FDB7C1B1A029D00F02AE3 /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = ""; };
46 | 4D0FDB7F1B1A029D00F02AE3 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/LaunchScreen.xib; sourceTree = ""; };
47 | 4D0FDB851B1A029D00F02AE3 /* YKPageViewTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = YKPageViewTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
48 | 4D0FDB8A1B1A029D00F02AE3 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; };
49 | 4D0FDB8B1B1A029D00F02AE3 /* YKPageViewTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = YKPageViewTests.m; sourceTree = ""; };
50 | 4D0FDB9A1B1A02BD00F02AE3 /* YKPageCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = YKPageCell.h; sourceTree = ""; };
51 | 4D0FDB9B1B1A02BD00F02AE3 /* YKPageCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = YKPageCell.m; sourceTree = ""; };
52 | 4D0FDB9C1B1A02BD00F02AE3 /* YKPageView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = YKPageView.h; sourceTree = ""; };
53 | 4D0FDB9D1B1A02BD00F02AE3 /* YKPageView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = YKPageView.m; sourceTree = ""; };
54 | 4D0FDBA31B1A02E300F02AE3 /* UIColor+Random.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIColor+Random.h"; sourceTree = ""; };
55 | 4D0FDBA41B1A02E300F02AE3 /* UIColor+Random.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIColor+Random.m"; sourceTree = ""; };
56 | 4DF26ED31BAAF1FC0025AA06 /* YKFooldView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = YKFooldView.h; sourceTree = ""; };
57 | 4DF26ED41BAAF1FC0025AA06 /* YKFooldView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = YKFooldView.m; sourceTree = ""; };
58 | 4DF26ED51BAAF1FC0025AA06 /* YKMenuItem.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = YKMenuItem.h; sourceTree = ""; };
59 | 4DF26ED61BAAF1FC0025AA06 /* YKMenuItem.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = YKMenuItem.m; sourceTree = ""; };
60 | 4DF26ED91BAAF31A0025AA06 /* YKMenuView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = YKMenuView.h; sourceTree = ""; };
61 | 4DF26EDA1BAAF31A0025AA06 /* YKMenuView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = YKMenuView.m; sourceTree = ""; };
62 | 4DF26EDC1BAAF4590025AA06 /* YKProgressView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = YKProgressView.h; sourceTree = ""; };
63 | 4DF26EDD1BAAF4590025AA06 /* YKProgressView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = YKProgressView.m; sourceTree = ""; };
64 | /* End PBXFileReference section */
65 |
66 | /* Begin PBXFrameworksBuildPhase section */
67 | 4D0FDB691B1A029D00F02AE3 /* Frameworks */ = {
68 | isa = PBXFrameworksBuildPhase;
69 | buildActionMask = 2147483647;
70 | files = (
71 | );
72 | runOnlyForDeploymentPostprocessing = 0;
73 | };
74 | 4D0FDB821B1A029D00F02AE3 /* Frameworks */ = {
75 | isa = PBXFrameworksBuildPhase;
76 | buildActionMask = 2147483647;
77 | files = (
78 | );
79 | runOnlyForDeploymentPostprocessing = 0;
80 | };
81 | /* End PBXFrameworksBuildPhase section */
82 |
83 | /* Begin PBXGroup section */
84 | 4D0FDB631B1A029D00F02AE3 = {
85 | isa = PBXGroup;
86 | children = (
87 | 4D0FDB6E1B1A029D00F02AE3 /* YKPageView */,
88 | 4D0FDB881B1A029D00F02AE3 /* YKPageViewTests */,
89 | 4D0FDB6D1B1A029D00F02AE3 /* Products */,
90 | );
91 | sourceTree = "";
92 | };
93 | 4D0FDB6D1B1A029D00F02AE3 /* Products */ = {
94 | isa = PBXGroup;
95 | children = (
96 | 4D0FDB6C1B1A029D00F02AE3 /* YKPageView.app */,
97 | 4D0FDB851B1A029D00F02AE3 /* YKPageViewTests.xctest */,
98 | );
99 | name = Products;
100 | sourceTree = "";
101 | };
102 | 4D0FDB6E1B1A029D00F02AE3 /* YKPageView */ = {
103 | isa = PBXGroup;
104 | children = (
105 | 4D0FDBA21B1A02D300F02AE3 /* Category */,
106 | 4D0FDB951B1A02BD00F02AE3 /* PageView */,
107 | 4D0FDB731B1A029D00F02AE3 /* AppDelegate.h */,
108 | 4D0FDB741B1A029D00F02AE3 /* AppDelegate.m */,
109 | 4D0FDB761B1A029D00F02AE3 /* ViewController.h */,
110 | 4D0FDB771B1A029D00F02AE3 /* ViewController.m */,
111 | 4D0FDB791B1A029D00F02AE3 /* Main.storyboard */,
112 | 4D0FDB7C1B1A029D00F02AE3 /* Images.xcassets */,
113 | 4D0FDB7E1B1A029D00F02AE3 /* LaunchScreen.xib */,
114 | 4D0FDB6F1B1A029D00F02AE3 /* Supporting Files */,
115 | );
116 | path = YKPageView;
117 | sourceTree = "";
118 | };
119 | 4D0FDB6F1B1A029D00F02AE3 /* Supporting Files */ = {
120 | isa = PBXGroup;
121 | children = (
122 | 4D0FDB701B1A029D00F02AE3 /* Info.plist */,
123 | 4D0FDB711B1A029D00F02AE3 /* main.m */,
124 | );
125 | name = "Supporting Files";
126 | sourceTree = "";
127 | };
128 | 4D0FDB881B1A029D00F02AE3 /* YKPageViewTests */ = {
129 | isa = PBXGroup;
130 | children = (
131 | 4D0FDB8B1B1A029D00F02AE3 /* YKPageViewTests.m */,
132 | 4D0FDB891B1A029D00F02AE3 /* Supporting Files */,
133 | );
134 | path = YKPageViewTests;
135 | sourceTree = "";
136 | };
137 | 4D0FDB891B1A029D00F02AE3 /* Supporting Files */ = {
138 | isa = PBXGroup;
139 | children = (
140 | 4D0FDB8A1B1A029D00F02AE3 /* Info.plist */,
141 | );
142 | name = "Supporting Files";
143 | sourceTree = "";
144 | };
145 | 4D0FDB951B1A02BD00F02AE3 /* PageView */ = {
146 | isa = PBXGroup;
147 | children = (
148 | 4D0FDB9C1B1A02BD00F02AE3 /* YKPageView.h */,
149 | 4D0FDB9D1B1A02BD00F02AE3 /* YKPageView.m */,
150 | 4D0FDB9A1B1A02BD00F02AE3 /* YKPageCell.h */,
151 | 4D0FDB9B1B1A02BD00F02AE3 /* YKPageCell.m */,
152 | 4DF26EDF1BAAF5700025AA06 /* MenuView */,
153 | );
154 | name = PageView;
155 | path = MenuView;
156 | sourceTree = "";
157 | };
158 | 4D0FDBA21B1A02D300F02AE3 /* Category */ = {
159 | isa = PBXGroup;
160 | children = (
161 | 4D0FDBA31B1A02E300F02AE3 /* UIColor+Random.h */,
162 | 4D0FDBA41B1A02E300F02AE3 /* UIColor+Random.m */,
163 | );
164 | name = Category;
165 | sourceTree = "";
166 | };
167 | 4DF26EDF1BAAF5700025AA06 /* MenuView */ = {
168 | isa = PBXGroup;
169 | children = (
170 | 4DF26ED51BAAF1FC0025AA06 /* YKMenuItem.h */,
171 | 4DF26ED61BAAF1FC0025AA06 /* YKMenuItem.m */,
172 | 4DF26ED91BAAF31A0025AA06 /* YKMenuView.h */,
173 | 4DF26EDA1BAAF31A0025AA06 /* YKMenuView.m */,
174 | 4DF26ED31BAAF1FC0025AA06 /* YKFooldView.h */,
175 | 4DF26ED41BAAF1FC0025AA06 /* YKFooldView.m */,
176 | 4DF26EDC1BAAF4590025AA06 /* YKProgressView.h */,
177 | 4DF26EDD1BAAF4590025AA06 /* YKProgressView.m */,
178 | );
179 | name = MenuView;
180 | sourceTree = "";
181 | };
182 | /* End PBXGroup section */
183 |
184 | /* Begin PBXNativeTarget section */
185 | 4D0FDB6B1B1A029D00F02AE3 /* YKPageView */ = {
186 | isa = PBXNativeTarget;
187 | buildConfigurationList = 4D0FDB8F1B1A029D00F02AE3 /* Build configuration list for PBXNativeTarget "YKPageView" */;
188 | buildPhases = (
189 | 4D0FDB681B1A029D00F02AE3 /* Sources */,
190 | 4D0FDB691B1A029D00F02AE3 /* Frameworks */,
191 | 4D0FDB6A1B1A029D00F02AE3 /* Resources */,
192 | );
193 | buildRules = (
194 | );
195 | dependencies = (
196 | );
197 | name = YKPageView;
198 | productName = YKPageView;
199 | productReference = 4D0FDB6C1B1A029D00F02AE3 /* YKPageView.app */;
200 | productType = "com.apple.product-type.application";
201 | };
202 | 4D0FDB841B1A029D00F02AE3 /* YKPageViewTests */ = {
203 | isa = PBXNativeTarget;
204 | buildConfigurationList = 4D0FDB921B1A029D00F02AE3 /* Build configuration list for PBXNativeTarget "YKPageViewTests" */;
205 | buildPhases = (
206 | 4D0FDB811B1A029D00F02AE3 /* Sources */,
207 | 4D0FDB821B1A029D00F02AE3 /* Frameworks */,
208 | 4D0FDB831B1A029D00F02AE3 /* Resources */,
209 | );
210 | buildRules = (
211 | );
212 | dependencies = (
213 | 4D0FDB871B1A029D00F02AE3 /* PBXTargetDependency */,
214 | );
215 | name = YKPageViewTests;
216 | productName = YKPageViewTests;
217 | productReference = 4D0FDB851B1A029D00F02AE3 /* YKPageViewTests.xctest */;
218 | productType = "com.apple.product-type.bundle.unit-test";
219 | };
220 | /* End PBXNativeTarget section */
221 |
222 | /* Begin PBXProject section */
223 | 4D0FDB641B1A029D00F02AE3 /* Project object */ = {
224 | isa = PBXProject;
225 | attributes = {
226 | LastUpgradeCheck = 0630;
227 | ORGANIZATIONNAME = yq;
228 | TargetAttributes = {
229 | 4D0FDB6B1B1A029D00F02AE3 = {
230 | CreatedOnToolsVersion = 6.3.1;
231 | };
232 | 4D0FDB841B1A029D00F02AE3 = {
233 | CreatedOnToolsVersion = 6.3.1;
234 | TestTargetID = 4D0FDB6B1B1A029D00F02AE3;
235 | };
236 | };
237 | };
238 | buildConfigurationList = 4D0FDB671B1A029D00F02AE3 /* Build configuration list for PBXProject "YKPageView" */;
239 | compatibilityVersion = "Xcode 3.2";
240 | developmentRegion = English;
241 | hasScannedForEncodings = 0;
242 | knownRegions = (
243 | en,
244 | Base,
245 | );
246 | mainGroup = 4D0FDB631B1A029D00F02AE3;
247 | productRefGroup = 4D0FDB6D1B1A029D00F02AE3 /* Products */;
248 | projectDirPath = "";
249 | projectRoot = "";
250 | targets = (
251 | 4D0FDB6B1B1A029D00F02AE3 /* YKPageView */,
252 | 4D0FDB841B1A029D00F02AE3 /* YKPageViewTests */,
253 | );
254 | };
255 | /* End PBXProject section */
256 |
257 | /* Begin PBXResourcesBuildPhase section */
258 | 4D0FDB6A1B1A029D00F02AE3 /* Resources */ = {
259 | isa = PBXResourcesBuildPhase;
260 | buildActionMask = 2147483647;
261 | files = (
262 | 4D0FDB7B1B1A029D00F02AE3 /* Main.storyboard in Resources */,
263 | 4D0FDB801B1A029D00F02AE3 /* LaunchScreen.xib in Resources */,
264 | 4D0FDB7D1B1A029D00F02AE3 /* Images.xcassets in Resources */,
265 | );
266 | runOnlyForDeploymentPostprocessing = 0;
267 | };
268 | 4D0FDB831B1A029D00F02AE3 /* Resources */ = {
269 | isa = PBXResourcesBuildPhase;
270 | buildActionMask = 2147483647;
271 | files = (
272 | );
273 | runOnlyForDeploymentPostprocessing = 0;
274 | };
275 | /* End PBXResourcesBuildPhase section */
276 |
277 | /* Begin PBXSourcesBuildPhase section */
278 | 4D0FDB681B1A029D00F02AE3 /* Sources */ = {
279 | isa = PBXSourcesBuildPhase;
280 | buildActionMask = 2147483647;
281 | files = (
282 | 4DF26ED71BAAF1FC0025AA06 /* YKFooldView.m in Sources */,
283 | 4DF26ED81BAAF1FC0025AA06 /* YKMenuItem.m in Sources */,
284 | 4D0FDB781B1A029D00F02AE3 /* ViewController.m in Sources */,
285 | 4D0FDBA01B1A02BD00F02AE3 /* YKPageCell.m in Sources */,
286 | 4D0FDB751B1A029D00F02AE3 /* AppDelegate.m in Sources */,
287 | 4DF26EDB1BAAF31A0025AA06 /* YKMenuView.m in Sources */,
288 | 4DF26EDE1BAAF4590025AA06 /* YKProgressView.m in Sources */,
289 | 4D0FDBA51B1A02E300F02AE3 /* UIColor+Random.m in Sources */,
290 | 4D0FDBA11B1A02BD00F02AE3 /* YKPageView.m in Sources */,
291 | 4D0FDB721B1A029D00F02AE3 /* main.m in Sources */,
292 | );
293 | runOnlyForDeploymentPostprocessing = 0;
294 | };
295 | 4D0FDB811B1A029D00F02AE3 /* Sources */ = {
296 | isa = PBXSourcesBuildPhase;
297 | buildActionMask = 2147483647;
298 | files = (
299 | 4D0FDB8C1B1A029D00F02AE3 /* YKPageViewTests.m in Sources */,
300 | );
301 | runOnlyForDeploymentPostprocessing = 0;
302 | };
303 | /* End PBXSourcesBuildPhase section */
304 |
305 | /* Begin PBXTargetDependency section */
306 | 4D0FDB871B1A029D00F02AE3 /* PBXTargetDependency */ = {
307 | isa = PBXTargetDependency;
308 | target = 4D0FDB6B1B1A029D00F02AE3 /* YKPageView */;
309 | targetProxy = 4D0FDB861B1A029D00F02AE3 /* PBXContainerItemProxy */;
310 | };
311 | /* End PBXTargetDependency section */
312 |
313 | /* Begin PBXVariantGroup section */
314 | 4D0FDB791B1A029D00F02AE3 /* Main.storyboard */ = {
315 | isa = PBXVariantGroup;
316 | children = (
317 | 4D0FDB7A1B1A029D00F02AE3 /* Base */,
318 | );
319 | name = Main.storyboard;
320 | sourceTree = "";
321 | };
322 | 4D0FDB7E1B1A029D00F02AE3 /* LaunchScreen.xib */ = {
323 | isa = PBXVariantGroup;
324 | children = (
325 | 4D0FDB7F1B1A029D00F02AE3 /* Base */,
326 | );
327 | name = LaunchScreen.xib;
328 | sourceTree = "";
329 | };
330 | /* End PBXVariantGroup section */
331 |
332 | /* Begin XCBuildConfiguration section */
333 | 4D0FDB8D1B1A029D00F02AE3 /* Debug */ = {
334 | isa = XCBuildConfiguration;
335 | buildSettings = {
336 | ALWAYS_SEARCH_USER_PATHS = NO;
337 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
338 | CLANG_CXX_LIBRARY = "libc++";
339 | CLANG_ENABLE_MODULES = YES;
340 | CLANG_ENABLE_OBJC_ARC = YES;
341 | CLANG_WARN_BOOL_CONVERSION = YES;
342 | CLANG_WARN_CONSTANT_CONVERSION = YES;
343 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
344 | CLANG_WARN_EMPTY_BODY = YES;
345 | CLANG_WARN_ENUM_CONVERSION = YES;
346 | CLANG_WARN_INT_CONVERSION = YES;
347 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
348 | CLANG_WARN_UNREACHABLE_CODE = YES;
349 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
350 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
351 | COPY_PHASE_STRIP = NO;
352 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
353 | ENABLE_STRICT_OBJC_MSGSEND = YES;
354 | GCC_C_LANGUAGE_STANDARD = gnu99;
355 | GCC_DYNAMIC_NO_PIC = NO;
356 | GCC_NO_COMMON_BLOCKS = YES;
357 | GCC_OPTIMIZATION_LEVEL = 0;
358 | GCC_PREPROCESSOR_DEFINITIONS = (
359 | "DEBUG=1",
360 | "$(inherited)",
361 | );
362 | GCC_SYMBOLS_PRIVATE_EXTERN = NO;
363 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
364 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
365 | GCC_WARN_UNDECLARED_SELECTOR = YES;
366 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
367 | GCC_WARN_UNUSED_FUNCTION = YES;
368 | GCC_WARN_UNUSED_VARIABLE = YES;
369 | IPHONEOS_DEPLOYMENT_TARGET = 8.3;
370 | MTL_ENABLE_DEBUG_INFO = YES;
371 | ONLY_ACTIVE_ARCH = YES;
372 | SDKROOT = iphoneos;
373 | };
374 | name = Debug;
375 | };
376 | 4D0FDB8E1B1A029D00F02AE3 /* Release */ = {
377 | isa = XCBuildConfiguration;
378 | buildSettings = {
379 | ALWAYS_SEARCH_USER_PATHS = NO;
380 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
381 | CLANG_CXX_LIBRARY = "libc++";
382 | CLANG_ENABLE_MODULES = YES;
383 | CLANG_ENABLE_OBJC_ARC = YES;
384 | CLANG_WARN_BOOL_CONVERSION = YES;
385 | CLANG_WARN_CONSTANT_CONVERSION = YES;
386 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
387 | CLANG_WARN_EMPTY_BODY = YES;
388 | CLANG_WARN_ENUM_CONVERSION = YES;
389 | CLANG_WARN_INT_CONVERSION = YES;
390 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
391 | CLANG_WARN_UNREACHABLE_CODE = YES;
392 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
393 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
394 | COPY_PHASE_STRIP = NO;
395 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
396 | ENABLE_NS_ASSERTIONS = NO;
397 | ENABLE_STRICT_OBJC_MSGSEND = YES;
398 | GCC_C_LANGUAGE_STANDARD = gnu99;
399 | GCC_NO_COMMON_BLOCKS = YES;
400 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
401 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
402 | GCC_WARN_UNDECLARED_SELECTOR = YES;
403 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
404 | GCC_WARN_UNUSED_FUNCTION = YES;
405 | GCC_WARN_UNUSED_VARIABLE = YES;
406 | IPHONEOS_DEPLOYMENT_TARGET = 8.3;
407 | MTL_ENABLE_DEBUG_INFO = NO;
408 | SDKROOT = iphoneos;
409 | VALIDATE_PRODUCT = YES;
410 | };
411 | name = Release;
412 | };
413 | 4D0FDB901B1A029D00F02AE3 /* Debug */ = {
414 | isa = XCBuildConfiguration;
415 | buildSettings = {
416 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
417 | INFOPLIST_FILE = YKPageView/Info.plist;
418 | IPHONEOS_DEPLOYMENT_TARGET = 7.1;
419 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
420 | PRODUCT_NAME = "$(TARGET_NAME)";
421 | };
422 | name = Debug;
423 | };
424 | 4D0FDB911B1A029D00F02AE3 /* Release */ = {
425 | isa = XCBuildConfiguration;
426 | buildSettings = {
427 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
428 | INFOPLIST_FILE = YKPageView/Info.plist;
429 | IPHONEOS_DEPLOYMENT_TARGET = 7.1;
430 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
431 | PRODUCT_NAME = "$(TARGET_NAME)";
432 | };
433 | name = Release;
434 | };
435 | 4D0FDB931B1A029D00F02AE3 /* Debug */ = {
436 | isa = XCBuildConfiguration;
437 | buildSettings = {
438 | BUNDLE_LOADER = "$(TEST_HOST)";
439 | FRAMEWORK_SEARCH_PATHS = (
440 | "$(SDKROOT)/Developer/Library/Frameworks",
441 | "$(inherited)",
442 | );
443 | GCC_PREPROCESSOR_DEFINITIONS = (
444 | "DEBUG=1",
445 | "$(inherited)",
446 | );
447 | INFOPLIST_FILE = YKPageViewTests/Info.plist;
448 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
449 | PRODUCT_NAME = "$(TARGET_NAME)";
450 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/YKPageView.app/YKPageView";
451 | };
452 | name = Debug;
453 | };
454 | 4D0FDB941B1A029D00F02AE3 /* Release */ = {
455 | isa = XCBuildConfiguration;
456 | buildSettings = {
457 | BUNDLE_LOADER = "$(TEST_HOST)";
458 | FRAMEWORK_SEARCH_PATHS = (
459 | "$(SDKROOT)/Developer/Library/Frameworks",
460 | "$(inherited)",
461 | );
462 | INFOPLIST_FILE = YKPageViewTests/Info.plist;
463 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
464 | PRODUCT_NAME = "$(TARGET_NAME)";
465 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/YKPageView.app/YKPageView";
466 | };
467 | name = Release;
468 | };
469 | /* End XCBuildConfiguration section */
470 |
471 | /* Begin XCConfigurationList section */
472 | 4D0FDB671B1A029D00F02AE3 /* Build configuration list for PBXProject "YKPageView" */ = {
473 | isa = XCConfigurationList;
474 | buildConfigurations = (
475 | 4D0FDB8D1B1A029D00F02AE3 /* Debug */,
476 | 4D0FDB8E1B1A029D00F02AE3 /* Release */,
477 | );
478 | defaultConfigurationIsVisible = 0;
479 | defaultConfigurationName = Release;
480 | };
481 | 4D0FDB8F1B1A029D00F02AE3 /* Build configuration list for PBXNativeTarget "YKPageView" */ = {
482 | isa = XCConfigurationList;
483 | buildConfigurations = (
484 | 4D0FDB901B1A029D00F02AE3 /* Debug */,
485 | 4D0FDB911B1A029D00F02AE3 /* Release */,
486 | );
487 | defaultConfigurationIsVisible = 0;
488 | defaultConfigurationName = Release;
489 | };
490 | 4D0FDB921B1A029D00F02AE3 /* Build configuration list for PBXNativeTarget "YKPageViewTests" */ = {
491 | isa = XCConfigurationList;
492 | buildConfigurations = (
493 | 4D0FDB931B1A029D00F02AE3 /* Debug */,
494 | 4D0FDB941B1A029D00F02AE3 /* Release */,
495 | );
496 | defaultConfigurationIsVisible = 0;
497 | defaultConfigurationName = Release;
498 | };
499 | /* End XCConfigurationList section */
500 | };
501 | rootObject = 4D0FDB641B1A029D00F02AE3 /* Project object */;
502 | }
503 |
--------------------------------------------------------------------------------
/YKPageView.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/YKPageView.xcodeproj/project.xcworkspace/xcshareddata/YKPageView.xccheckout:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | IDESourceControlProjectFavoriteDictionaryKey
6 |
7 | IDESourceControlProjectIdentifier
8 | F46541E8-0F66-4CDB-9F44-CCF334E23FAE
9 | IDESourceControlProjectName
10 | YKPageView
11 | IDESourceControlProjectOriginsDictionary
12 |
13 | 2DE65555B6115C7F6AC0A2C54AF173771E6780B4
14 | https://github.com/wangmchn/YKPageView.git
15 |
16 | IDESourceControlProjectPath
17 | YKPageView.xcodeproj
18 | IDESourceControlProjectRelativeInstallPathDictionary
19 |
20 | 2DE65555B6115C7F6AC0A2C54AF173771E6780B4
21 | ../..
22 |
23 | IDESourceControlProjectURL
24 | https://github.com/wangmchn/YKPageView.git
25 | IDESourceControlProjectVersion
26 | 111
27 | IDESourceControlProjectWCCIdentifier
28 | 2DE65555B6115C7F6AC0A2C54AF173771E6780B4
29 | IDESourceControlProjectWCConfigurations
30 |
31 |
32 | IDESourceControlRepositoryExtensionIdentifierKey
33 | public.vcs.git
34 | IDESourceControlWCCIdentifierKey
35 | 2DE65555B6115C7F6AC0A2C54AF173771E6780B4
36 | IDESourceControlWCCName
37 | YKPageView
38 |
39 |
40 |
41 |
42 |
--------------------------------------------------------------------------------
/YKPageView.xcodeproj/project.xcworkspace/xcuserdata/Mark.xcuserdatad/UserInterfaceState.xcuserstate:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wangmchn/YKPageView/a008f2d686dd817ce9b1332ac5a79d5bc5866c44/YKPageView.xcodeproj/project.xcworkspace/xcuserdata/Mark.xcuserdatad/UserInterfaceState.xcuserstate
--------------------------------------------------------------------------------
/YKPageView.xcodeproj/project.xcworkspace/xcuserdata/Mark.xcuserdatad/WorkspaceSettings.xcsettings:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | HasAskedToTakeAutomaticSnapshotBeforeSignificantChanges
6 |
7 | SnapshotAutomaticallyBeforeSignificantChanges
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/YKPageView.xcodeproj/xcuserdata/Mark.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
--------------------------------------------------------------------------------
/YKPageView.xcodeproj/xcuserdata/Mark.xcuserdatad/xcschemes/YKPageView.xcscheme:
--------------------------------------------------------------------------------
1 |
2 |
5 |
8 |
9 |
15 |
21 |
22 |
23 |
29 |
35 |
36 |
37 |
38 |
39 |
44 |
45 |
47 |
53 |
54 |
55 |
56 |
57 |
63 |
64 |
65 |
66 |
75 |
77 |
83 |
84 |
85 |
86 |
87 |
88 |
94 |
96 |
102 |
103 |
104 |
105 |
107 |
108 |
111 |
112 |
113 |
--------------------------------------------------------------------------------
/YKPageView.xcodeproj/xcuserdata/Mark.xcuserdatad/xcschemes/xcschememanagement.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | SchemeUserState
6 |
7 | YKPageView.xcscheme
8 |
9 | orderHint
10 | 0
11 |
12 |
13 | SuppressBuildableAutocreation
14 |
15 | 4D0FDB6B1B1A029D00F02AE3
16 |
17 | primary
18 |
19 |
20 | 4D0FDB841B1A029D00F02AE3
21 |
22 | primary
23 |
24 |
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/YKPageView/AppDelegate.h:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.h
3 | // YKPageView
4 | //
5 | // Created by Mark on 15/5/30.
6 | // Copyright (c) 2015年 yq. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface AppDelegate : UIResponder
12 |
13 | @property (strong, nonatomic) UIWindow *window;
14 |
15 |
16 | @end
17 |
18 |
--------------------------------------------------------------------------------
/YKPageView/AppDelegate.m:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.m
3 | // YKPageView
4 | //
5 | // Created by Mark on 15/5/30.
6 | // Copyright (c) 2015年 yq. All rights reserved.
7 | //
8 |
9 | #import "AppDelegate.h"
10 | #import "ViewController.h"
11 | @interface AppDelegate ()
12 |
13 | @end
14 |
15 | @implementation AppDelegate
16 |
17 |
18 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
19 | // Override point for customization after application launch.
20 | ViewController *vc = [[ViewController alloc] init];
21 | UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:vc];
22 | self.window.rootViewController = nav;
23 | self.window.backgroundColor = [UIColor whiteColor];
24 | return YES;
25 | }
26 |
27 | - (void)applicationWillResignActive:(UIApplication *)application {
28 | // 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.
29 | // 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.
30 | }
31 |
32 | - (void)applicationDidEnterBackground:(UIApplication *)application {
33 | // 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.
34 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
35 | }
36 |
37 | - (void)applicationWillEnterForeground:(UIApplication *)application {
38 | // 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.
39 | }
40 |
41 | - (void)applicationDidBecomeActive:(UIApplication *)application {
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 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
47 | }
48 |
49 | @end
50 |
--------------------------------------------------------------------------------
/YKPageView/Base.lproj/LaunchScreen.xib:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
20 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
--------------------------------------------------------------------------------
/YKPageView/Base.lproj/Main.storyboard:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/YKPageView/Images.xcassets/AppIcon.appiconset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "iphone",
5 | "size" : "29x29",
6 | "scale" : "2x"
7 | },
8 | {
9 | "idiom" : "iphone",
10 | "size" : "29x29",
11 | "scale" : "3x"
12 | },
13 | {
14 | "idiom" : "iphone",
15 | "size" : "40x40",
16 | "scale" : "2x"
17 | },
18 | {
19 | "idiom" : "iphone",
20 | "size" : "40x40",
21 | "scale" : "3x"
22 | },
23 | {
24 | "idiom" : "iphone",
25 | "size" : "60x60",
26 | "scale" : "2x"
27 | },
28 | {
29 | "idiom" : "iphone",
30 | "size" : "60x60",
31 | "scale" : "3x"
32 | }
33 | ],
34 | "info" : {
35 | "version" : 1,
36 | "author" : "xcode"
37 | }
38 | }
--------------------------------------------------------------------------------
/YKPageView/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIdentifier
10 | Shellv.$(PRODUCT_NAME:rfc1034identifier)
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundleName
14 | $(PRODUCT_NAME)
15 | CFBundlePackageType
16 | APPL
17 | CFBundleShortVersionString
18 | 1.0
19 | CFBundleSignature
20 | ????
21 | CFBundleVersion
22 | 1
23 | LSRequiresIPhoneOS
24 |
25 | UILaunchStoryboardName
26 | LaunchScreen
27 | UIMainStoryboardFile
28 | Main
29 | UIRequiredDeviceCapabilities
30 |
31 | armv7
32 |
33 | UISupportedInterfaceOrientations
34 |
35 | UIInterfaceOrientationPortrait
36 | UIInterfaceOrientationLandscapeLeft
37 | UIInterfaceOrientationLandscapeRight
38 |
39 |
40 |
41 |
--------------------------------------------------------------------------------
/YKPageView/MenuView/YKFooldView.h:
--------------------------------------------------------------------------------
1 | //
2 | // YKFooldView.h
3 | // YKPageView
4 | //
5 | // Created by Mark on 15/7/13.
6 | // Copyright (c) 2015年 yq. All rights reserved.
7 | //
8 |
9 | #import "YKProgressView.h"
10 |
11 | @interface YKFooldView : YKProgressView
12 | @property (nonatomic, assign) BOOL hollow;
13 | @end
14 |
--------------------------------------------------------------------------------
/YKPageView/MenuView/YKFooldView.m:
--------------------------------------------------------------------------------
1 | //
2 | // YKFooldView.m
3 | // YKPageView
4 | //
5 | // Created by Mark on 15/7/13.
6 | // Copyright (c) 2015年 yq. All rights reserved.
7 | //
8 |
9 | #import "YKFooldView.h"
10 |
11 | @implementation YKFooldView {
12 | CGFloat YKFooldMargin;
13 | CGFloat YKFooldRadius;
14 | CGFloat YKFooldLength;
15 | CGFloat YKFooldHeight;
16 | CGFloat gap;
17 | CGFloat step;
18 | CGFloat kTime;
19 | int sign;
20 |
21 | __weak CADisplayLink *_link;
22 | }
23 |
24 | @synthesize progress = _progress;
25 |
26 | - (instancetype)initWithFrame:(CGRect)frame {
27 | if (self = [super initWithFrame:frame]) {
28 | YKFooldHeight = frame.size.height;
29 | YKFooldMargin = YKFooldHeight * 0.15;
30 | YKFooldRadius = (YKFooldHeight - YKFooldMargin * 2) / 2;
31 | YKFooldLength = frame.size.width - YKFooldRadius * 2;
32 | kTime = 20.0;
33 | }
34 | return self;
35 | }
36 |
37 | - (void)setProgressWithOutAnimate:(CGFloat)progress {
38 | if (self.progress == progress) return;
39 | _progress = progress;
40 | [self setNeedsDisplay];
41 | }
42 |
43 | - (void)setProgress:(CGFloat)progress {
44 | if (self.progress == progress) return;
45 | if (fabs(progress - _progress) >= 0.9 /*&& fabs(progress - _progress) < 1.5*/) {
46 | gap = fabs(self.progress - progress);
47 | sign = self.progress > progress ? - 1 : 1;
48 | if (self.itemFrames.count <= 3) {
49 | kTime = 15.0;
50 | }
51 | step = gap / kTime;
52 | CADisplayLink *link = [CADisplayLink displayLinkWithTarget:self selector:@selector(progressChanged)];
53 | [link addToRunLoop:[NSRunLoop mainRunLoop] forMode:NSRunLoopCommonModes];
54 | _link = link;
55 | return;
56 | }
57 | _progress = progress;
58 | [self setNeedsDisplay];
59 | }
60 |
61 | - (void)progressChanged {
62 | if (gap >= 0.0) {
63 | gap -= step;
64 | if (gap < 0.0) {
65 | self.progress = (int)(self.progress + 0.5);
66 | return;
67 | }
68 | self.progress += sign * step;
69 | } else {
70 | self.progress = (int)(self.progress + 0.5);
71 | [_link invalidate];
72 | _link = nil;
73 | }
74 | }
75 |
76 | - (void)drawRect:(CGRect)rect {
77 | // Drawing code
78 | int currentIndex = (int)self.progress;
79 | CGFloat rate = self.progress - currentIndex;
80 | int nextIndex = currentIndex + 1 >= self.itemFrames.count ?: currentIndex + 1;
81 |
82 | // 当前item的各数值
83 | CGRect currentFrame = [self.itemFrames[currentIndex] CGRectValue];
84 | CGFloat currentWidth = currentFrame.size.width;
85 | CGFloat currentX = currentFrame.origin.x;
86 | // 下一个item的各数值
87 | CGFloat nextWidth = [self.itemFrames[nextIndex] CGRectValue].size.width;
88 | CGFloat nextX = [self.itemFrames[nextIndex] CGRectValue].origin.x;
89 | // 计算点
90 | CGFloat startX = currentX + (nextX - currentX) * rate;
91 | CGFloat endX = startX + currentWidth + (nextWidth - currentWidth)*rate;
92 | // 绘制
93 | CGContextRef ctx = UIGraphicsGetCurrentContext();
94 | CGContextTranslateCTM(ctx, 0.0f, YKFooldHeight);
95 | CGContextScaleCTM(ctx, 1.0f, -1.0f);
96 | CGContextAddArc(ctx, startX+YKFooldRadius, YKFooldHeight / 2.0, YKFooldRadius, M_PI_2, M_PI_2 * 3, 0);
97 | CGContextAddLineToPoint(ctx, endX-YKFooldRadius, YKFooldMargin);
98 | CGContextAddArc(ctx, endX-YKFooldRadius, YKFooldHeight / 2.0, YKFooldRadius, -M_PI_2, M_PI_2, 0);
99 | CGContextClosePath(ctx);
100 |
101 | if (self.hollow) {
102 | CGContextSetStrokeColorWithColor(ctx, self.color);
103 | CGContextStrokePath(ctx);
104 | return;
105 | }
106 | CGContextClosePath(ctx);
107 | CGContextSetFillColorWithColor(ctx, self.color);
108 | CGContextFillPath(ctx);
109 | }
110 |
111 | @end
112 |
--------------------------------------------------------------------------------
/YKPageView/MenuView/YKMenuItem.h:
--------------------------------------------------------------------------------
1 | //
2 | // YKMenuItem.h
3 | // YKPageView
4 | //
5 | // Created by Mark on 15/4/26.
6 | // Copyright (c) 2015年 yq. All rights reserved.
7 | //
8 |
9 | #import
10 | @class YKMenuItem;
11 | @protocol YKMenuItemDelegate
12 | @optional
13 | - (void)didPressedMenuItem:(YKMenuItem *)menuItem;
14 | @end
15 |
16 | @interface YKMenuItem : UILabel
17 |
18 | /** 设置rate,并刷新标题状态 */
19 | @property (nonatomic, assign) CGFloat rate;
20 |
21 | /** normal状态的字体大小,默认大小为15 */
22 | @property (nonatomic, assign) CGFloat normalSize;
23 |
24 | /** selected状态的字体大小,默认大小为18 */
25 | @property (nonatomic, assign) CGFloat selectedSize;
26 |
27 | /** normal状态的字体颜色,默认为黑色 (可动画) */
28 | @property (nonatomic, strong) UIColor *normalColor;
29 |
30 | /** selected状态的字体颜色,默认为红色 (可动画) */
31 | @property (nonatomic, strong) UIColor *selectedColor;
32 |
33 | @property (nonatomic, assign, getter=isSelected) BOOL selected;
34 | @property (nonatomic, weak) id delegate;
35 | - (void)selectedItemWithoutAnimation;
36 | - (void)deselectedItemWithoutAnimation;
37 | @end
38 |
--------------------------------------------------------------------------------
/YKPageView/MenuView/YKMenuItem.m:
--------------------------------------------------------------------------------
1 | //
2 | // YKMenuItem.m
3 | // YKPageView
4 | //
5 | // Created by Mark on 15/4/26.
6 | // Copyright (c) 2015年 yq. All rights reserved.
7 | //
8 |
9 | #import "YKMenuItem.h"
10 | #define kSelectedSize 18
11 | #define kNormalSize 15
12 | #define kSelectedColor [UIColor colorWithRed:168.0/255.0 green:20.0/255.0 blue:4/255.0 alpha:1]
13 | #define kNormalColor [UIColor colorWithRed:0 green:0 blue:0 alpha:1]
14 |
15 | @interface YKMenuItem () {
16 | CGFloat rgba[4];
17 | CGFloat rgbaGAP[4];
18 | BOOL hasRGBA;
19 | }
20 | @end
21 |
22 | @implementation YKMenuItem
23 |
24 | #pragma mark - Public Methods
25 | - (instancetype)initWithFrame:(CGRect)frame {
26 | if (self = [super initWithFrame:frame]) {
27 | hasRGBA = NO;
28 | _normalColor = kNormalColor;
29 | _selectedColor = kSelectedColor;
30 | _normalSize = kNormalSize;
31 | _selectedSize = kSelectedSize;
32 | }
33 | return self;
34 | }
35 |
36 | // 设置选中,隐式动画所在
37 | - (void)setSelected:(BOOL)selected {
38 | if (self.selected == selected) {
39 | return;
40 | }
41 | [UIView animateWithDuration:0.3 animations:^{
42 | if (self.selected == YES) {
43 | self.rate = 0.0;
44 | } else {
45 | self.rate = 1.0;
46 | }
47 | } completion:^(BOOL finished) {
48 | _selected = selected;
49 | }];
50 | }
51 |
52 | // 设置rate,并刷新标题状态
53 | - (void)setRate:(CGFloat)rate {
54 | _rate = rate;
55 | if (!hasRGBA) {
56 | [self setRBGA];
57 | }
58 | CGFloat r = rgba[0] + rgbaGAP[0]*self.rate;
59 | CGFloat g = rgba[1] + rgbaGAP[1]*self.rate;
60 | CGFloat b = rgba[2] + rgbaGAP[2]*self.rate;
61 | CGFloat a = rgba[3] + rgbaGAP[3]*self.rate;
62 | self.textColor = [UIColor colorWithRed:r green:g blue:b alpha:a];
63 | CGFloat minScale = self.normalSize / self.selectedSize;
64 | CGFloat trueScale = minScale + (1-minScale)*rate;
65 | self.transform = CGAffineTransformMakeScale(trueScale, trueScale);
66 | }
67 |
68 | - (void)selectedItemWithoutAnimation {
69 | self.rate = 1.0;
70 | _selected = YES;
71 | }
72 |
73 | - (void)deselectedItemWithoutAnimation {
74 | self.rate = 0;
75 | _selected = NO;
76 | }
77 |
78 | #pragma mark - Private Methods
79 | // 记录normal的rgba值以及nor和sel的r、g、b、a的差值,以便后续使用
80 | - (void)setRBGA {
81 | int numNormal = (int)CGColorGetNumberOfComponents(self.normalColor.CGColor);
82 | int numSelected = (int)CGColorGetNumberOfComponents(self.selectedColor.CGColor);
83 | if (numNormal == 4&&numSelected == 4) {
84 | // UIDeviceRGBColorSpace
85 | const CGFloat *norComponents = CGColorGetComponents(self.normalColor.CGColor);
86 | const CGFloat *selComponents = CGColorGetComponents(self.selectedColor.CGColor);
87 | rgba[0] = norComponents[0];
88 | rgbaGAP[0] = selComponents[0]-rgba[0];
89 | rgba[1] = norComponents[1];
90 | rgbaGAP[1] = selComponents[1]-rgba[1];
91 | rgba[2] = norComponents[2];
92 | rgbaGAP[2] = selComponents[2]-rgba[2];
93 | rgba[3] = norComponents[3];
94 | rgbaGAP[3] = selComponents[3]-rgba[3];
95 | } else if (numNormal == 2 || numSelected == 2) {
96 | // 将灰度空间 (grayColor blackColor ect.) 转为 RGBA 色彩空间
97 | if (numNormal == 2) {
98 | const CGFloat *norComponents = CGColorGetComponents(self.normalColor.CGColor);
99 | self.normalColor = [UIColor colorWithRed:norComponents[0] green:norComponents[0] blue:norComponents[0] alpha:norComponents[1]];
100 | }
101 | if (numSelected == 2) {
102 | const CGFloat *selComponents = CGColorGetComponents(self.selectedColor.CGColor);
103 | self.selectedColor = [UIColor colorWithRed:selComponents[0] green:selComponents[0] blue:selComponents[0] alpha:selComponents[1]];
104 | }
105 | [self setRBGA];
106 | return;
107 | } else {
108 | NSAssert(NO, @"Error with item's color (`titleColorSelected`), may use `colorWithRed:green:blue:alpha:` can solve the problem.");
109 | }
110 | hasRGBA = YES;
111 | }
112 |
113 | // 触摸事件,告诉代理被触摸(点击)
114 | - (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
115 | if ([self.delegate respondsToSelector:@selector(didPressedMenuItem:)]) {
116 | [self.delegate didPressedMenuItem:self];
117 | }
118 | }
119 |
120 | @end
121 |
--------------------------------------------------------------------------------
/YKPageView/MenuView/YKMenuView.h:
--------------------------------------------------------------------------------
1 | //
2 | // YKMenuView.h
3 | // YKPageView
4 | //
5 | // Created by Mark on 15/4/26.
6 | // Copyright (c) 2015年 yq. All rights reserved.
7 | //
8 |
9 | #import
10 | @class YKMenuView;
11 | @class YKMenuItem;
12 | typedef enum {
13 | YKMenuViewStyleDefault, // 默认
14 | YKMenuViewStyleLine, // 带下划线 (若要选中字体大小不变,设置选中和非选中大小一样即可)
15 | YKMenuViewStyleFoold, // 涌入效果 (填充)
16 | YKMenuViewStyleFooldHollow // 涌入效果 (空心的)
17 | } YKMenuViewStyle;
18 |
19 | @protocol YKMenuViewDelegate
20 | @optional
21 | - (void)menuView:(YKMenuView *)menu didSelesctedIndex:(NSInteger)index currentIndex:(NSInteger)currentIndex;
22 | - (CGFloat)menuView:(YKMenuView *)menu widthForItemAtIndex:(NSInteger)index;
23 | @end
24 |
25 | @interface YKMenuView : UIView
26 |
27 | @property (nonatomic, strong) NSArray *items;
28 | @property (nonatomic, assign) YKMenuViewStyle style;
29 | @property (nonatomic, strong) UIColor *lineColor;
30 | @property (nonatomic, weak) id delegate;
31 | @property (nonatomic, copy) NSString *fontName;
32 |
33 | - (instancetype)initWithFrame:(CGRect)frame buttonItems:(NSArray *)items backgroundColor:(UIColor *)bgColor norSize:(CGFloat)norSize selSize:(CGFloat)selSize norColor:(UIColor *)norColor selColor:(UIColor *)selColor;
34 | - (void)slideMenuAtProgress:(CGFloat)progress;
35 | - (void)selectItemAtIndex:(NSInteger)index;
36 | @end
37 |
--------------------------------------------------------------------------------
/YKPageView/MenuView/YKMenuView.m:
--------------------------------------------------------------------------------
1 | //
2 | // YKMenuView.m
3 | // YKPageView
4 | //
5 | // Created by Mark on 15/4/26.
6 | // Copyright (c) 2015年 yq. All rights reserved.
7 | //
8 |
9 | #import "YKMenuView.h"
10 | #import "YKMenuItem.h"
11 | #import "YKProgressView.h"
12 | #import "YKFooldView.h"
13 | // 导航菜单栏距边界的间距
14 | #define YKMenuMargin 0
15 | #define kMaskWidth 0
16 | #define kItemWidth 60
17 | #define kTagGap 6250
18 | #define kBGColor [UIColor colorWithRed:172.0/255.0 green:165.0/255.0 blue:162.0/255.0 alpha:1.0]
19 | @interface YKMenuView () {
20 | CGFloat _norSize;
21 | CGFloat _selSize;
22 | UIColor *_norColor;
23 | UIColor *_selColor;
24 | }
25 | @property (nonatomic, weak) UIScrollView *scrollView;
26 | @property (nonatomic, weak) YKProgressView *progressView;
27 | @property (nonatomic, weak) YKMenuItem *selItem;
28 | @property (nonatomic, strong) UIColor *bgColor;
29 | @property (nonatomic, strong) NSMutableArray *frames;
30 | @end
31 | // 下划线的高度
32 | static CGFloat const YKProgressHeight = 2.0;
33 |
34 | @implementation YKMenuView
35 |
36 | #pragma mark - Lazy
37 | - (UIColor *)lineColor {
38 | if (!_lineColor) {
39 | _lineColor = _selColor;
40 | }
41 | return _lineColor;
42 | }
43 |
44 | - (NSMutableArray *)frames {
45 | if (_frames == nil) {
46 | _frames = [NSMutableArray array];
47 | }
48 | return _frames;
49 | }
50 |
51 | #pragma mark - Public Methods
52 | - (instancetype)initWithFrame:(CGRect)frame buttonItems:(NSArray *)items backgroundColor:(UIColor *)bgColor norSize:(CGFloat)norSize selSize:(CGFloat)selSize norColor:(UIColor *)norColor selColor:(UIColor *)selColor {
53 | if (self = [super initWithFrame:frame]) {
54 | _items = items;
55 | if (bgColor) {
56 | _bgColor = bgColor;
57 | } else {
58 | _bgColor = kBGColor;
59 | }
60 | _norSize = norSize;
61 | _selSize = selSize;
62 | _norColor = norColor;
63 | _selColor = selColor;
64 | }
65 | return self;
66 | }
67 |
68 | - (void)slideMenuAtProgress:(CGFloat)progress {
69 | if (self.progressView) {
70 | self.progressView.progress = progress;
71 | }
72 | NSInteger tag = (NSInteger)progress + kTagGap;
73 | CGFloat rate = progress - tag + kTagGap;
74 | YKMenuItem *currentItem = (YKMenuItem *)[self viewWithTag:tag];
75 | YKMenuItem *nextItem = (YKMenuItem *)[self viewWithTag:tag+1];
76 | if (rate == 0.0) {
77 | rate = 1.0;
78 | self.selItem.rate = 0;
79 | [self.selItem deselectedItemWithoutAnimation];
80 | self.selItem = currentItem;
81 | self.selItem.rate = 1;
82 | [self.selItem selectedItemWithoutAnimation];
83 | [self refreshContenOffset];
84 | return;
85 | }
86 | currentItem.rate = 1-rate;
87 | nextItem.rate = rate;
88 | }
89 |
90 | - (void)selectItemAtIndex:(NSInteger)index {
91 | NSInteger tag = index + kTagGap;
92 | NSInteger currentIndex = self.selItem.tag - kTagGap;
93 | YKMenuItem *item = (YKMenuItem *)[self viewWithTag:tag];
94 | [self.selItem deselectedItemWithoutAnimation];
95 | self.selItem = item;
96 | [self.selItem selectedItemWithoutAnimation];
97 | [self.progressView setProgressWithOutAnimate:index];
98 | if ([self.delegate respondsToSelector:@selector(menuView:didSelesctedIndex:currentIndex:)]) {
99 | [self.delegate menuView:self didSelesctedIndex:index currentIndex:currentIndex];
100 | }
101 | [self refreshContenOffset];
102 | }
103 |
104 | #pragma mark - Private Methods
105 | - (void)willMoveToSuperview:(UIView *)newSuperview {
106 | [self addScrollView];
107 | [self addItems];
108 | [self makeStyle];
109 | }
110 |
111 | // 有没更好地命名
112 | - (void)makeStyle {
113 | switch (self.style) {
114 | case YKMenuViewStyleLine:
115 | [self addProgressView];
116 | break;
117 | case YKMenuViewStyleFoold:
118 | [self addFooldViewHollow:NO];
119 | break;
120 | case YKMenuViewStyleFooldHollow:
121 | [self addFooldViewHollow:YES];
122 | break;
123 | default:
124 | break;
125 | }
126 | }
127 |
128 | // 让选中的item位于中间
129 | - (void)refreshContenOffset {
130 | CGRect frame = self.selItem.frame;
131 | CGFloat itemX = frame.origin.x;
132 | CGFloat width = self.scrollView.frame.size.width;
133 | CGSize contentSize = self.scrollView.contentSize;
134 | if (itemX > width/2) {
135 | CGFloat targetX;
136 | if ((contentSize.width-itemX) <= width/2) {
137 | targetX = contentSize.width - width;
138 | } else {
139 | targetX = frame.origin.x - width/2 + frame.size.width/2;
140 | }
141 | // 应该有更好的解决方法
142 | if (targetX + width > contentSize.width) {
143 | targetX = contentSize.width - width;
144 | }
145 | [self.scrollView setContentOffset:CGPointMake(targetX, 0) animated:YES];
146 | } else {
147 | [self.scrollView setContentOffset:CGPointMake(0, 0) animated:YES];
148 | }
149 | }
150 |
151 | - (void)addScrollView {
152 | CGFloat width = self.frame.size.width;
153 | CGFloat height = self.frame.size.height;
154 | CGRect frame = CGRectMake(0, 0, width, height);
155 | UIScrollView *scrollView = [[UIScrollView alloc] initWithFrame:frame];
156 | scrollView.showsHorizontalScrollIndicator = NO;
157 | scrollView.showsVerticalScrollIndicator = NO;
158 | scrollView.backgroundColor = self.bgColor;
159 | [self addSubview:scrollView];
160 | self.scrollView = scrollView;
161 | }
162 |
163 | - (void)addItems {
164 | [self calculateItemFrames];
165 |
166 | for (int i = 0; i < self.items.count; i++) {
167 | CGRect frame = [self.frames[i] CGRectValue];
168 | YKMenuItem *item = [[YKMenuItem alloc] initWithFrame:frame];
169 | item.tag = (i+kTagGap);
170 | item.delegate = self;
171 | item.text = self.items[i];
172 | item.textAlignment = NSTextAlignmentCenter;
173 | item.textColor = _norColor;
174 | item.userInteractionEnabled = YES;
175 | if (self.fontName) {
176 | item.font = [UIFont fontWithName:self.fontName size:_selSize];
177 | } else {
178 | item.font = [UIFont systemFontOfSize:_selSize];
179 | }
180 | item.backgroundColor = [UIColor clearColor];
181 | item.normalSize = _norSize;
182 | item.selectedSize = _selSize;
183 | item.normalColor = _norColor;
184 | item.selectedColor = _selColor;
185 | if (i == 0) {
186 | [item selectedItemWithoutAnimation];
187 | self.selItem = item;
188 | } else {
189 | [item deselectedItemWithoutAnimation];
190 | }
191 | [self.scrollView addSubview:item];
192 | }
193 | }
194 |
195 | // 计算所有item的frame值,主要是为了适配所有item的宽度之和小于屏幕宽的情况
196 | // 这里与后面的 `-addItems` 做了重复的操作,并不是很合理
197 | - (void)calculateItemFrames {
198 | CGFloat contentWidth = YKMenuMargin;
199 | for (int i = 0; i < self.items.count; i++) {
200 | CGFloat itemW = kItemWidth;
201 | if ([self.delegate respondsToSelector:@selector(menuView:widthForItemAtIndex:)]) {
202 | itemW = [self.delegate menuView:self widthForItemAtIndex:i];
203 | }
204 | CGRect frame = CGRectMake(contentWidth, 0, itemW, self.frame.size.height);
205 | // 记录frame
206 | [self.frames addObject:[NSValue valueWithCGRect:frame]];
207 | contentWidth += itemW;
208 | }
209 | contentWidth += YKMenuMargin;
210 | // 如果总宽度小于屏幕宽,重新计算frame,为item间添加间距
211 | if (contentWidth < self.frame.size.width) {
212 | // 计算间距
213 | CGFloat distance = self.frame.size.width - contentWidth;
214 | CGFloat gap = distance / (self.items.count + 1);
215 | for (int i = 0; i < self.frames.count; i++) {
216 | CGRect frame = [self.frames[i] CGRectValue];
217 | frame.origin.x += gap * (i+1);
218 | self.frames[i] = [NSValue valueWithCGRect:frame];
219 | }
220 | contentWidth = self.frame.size.width;
221 | }
222 | self.scrollView.contentSize = CGSizeMake(contentWidth, self.frame.size.height);
223 | }
224 |
225 | // MARK:Progress View
226 | - (void)addProgressView {
227 | YKProgressView *pView = [[YKProgressView alloc] initWithFrame:CGRectMake(0, self.frame.size.height - YKProgressHeight, self.scrollView.contentSize.width, YKProgressHeight)];
228 | pView.itemFrames = self.frames;
229 | pView.color = self.lineColor.CGColor;
230 | pView.backgroundColor = [UIColor clearColor];
231 | self.progressView = pView;
232 | [self.scrollView addSubview:pView];
233 | }
234 |
235 | - (void)addFooldViewHollow:(BOOL)isHollow {
236 | YKFooldView *fooldView = [[YKFooldView alloc] initWithFrame:CGRectMake(0, 0, self.scrollView.contentSize.width, self.frame.size.height)];
237 | fooldView.itemFrames = self.frames;
238 | fooldView.color = self.lineColor.CGColor;
239 | fooldView.hollow = isHollow;
240 | fooldView.backgroundColor = [UIColor clearColor];
241 | self.progressView = fooldView;
242 | [self.scrollView insertSubview:fooldView atIndex:0];
243 | }
244 |
245 | #pragma mark - Menu item delegate
246 | - (void)didPressedMenuItem:(YKMenuItem *)menuItem {
247 | if (self.selItem == menuItem) return;
248 |
249 | CGFloat progress = menuItem.tag - kTagGap;
250 | self.progressView.progress = progress;
251 |
252 | NSInteger currentIndex = self.selItem.tag - kTagGap;
253 | if ([self.delegate respondsToSelector:@selector(menuView:didSelesctedIndex:currentIndex:)]) {
254 | [self.delegate menuView:self didSelesctedIndex:menuItem.tag-kTagGap currentIndex:currentIndex];
255 | }
256 |
257 | menuItem.selected = YES;
258 | self.selItem.selected = NO;
259 | self.selItem = menuItem;
260 | // 让选中的item位于中间
261 | [self refreshContenOffset];
262 | }
263 |
264 | @end
265 |
--------------------------------------------------------------------------------
/YKPageView/MenuView/YKPageCell.h:
--------------------------------------------------------------------------------
1 | //
2 | // YKPageCell.h
3 | // YKPageView
4 | //
5 | // Created by Mark on 15/4/27.
6 | // Copyright (c) 2015年 yq. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface YKPageCell : UIView
12 | @property (nonatomic, copy) NSString *identifier;
13 |
14 | - (id)initWithIdentifier:(NSString *)identifier;
15 |
16 | @end
17 |
--------------------------------------------------------------------------------
/YKPageView/MenuView/YKPageCell.m:
--------------------------------------------------------------------------------
1 | //
2 | // YKPageCell.m
3 | // YKPageView
4 | //
5 | // Created by Mark on 15/4/27.
6 | // Copyright (c) 2015年 yq. All rights reserved.
7 | //
8 |
9 | #import "YKPageCell.h"
10 |
11 | @implementation YKPageCell
12 |
13 | - (id)initWithIdentifier:(NSString *)identifier{
14 | if (self = [super init]) {
15 | _identifier = identifier;
16 | }
17 | return self;
18 | }
19 |
20 | @end
21 |
--------------------------------------------------------------------------------
/YKPageView/MenuView/YKPageView.h:
--------------------------------------------------------------------------------
1 | //
2 | // YKPageView.h
3 | // YKPageView
4 | //
5 | // Created by Mark on 15/4/27.
6 | // Copyright (c) 2015年 yq. All rights reserved.
7 | //
8 |
9 | #import
10 | #import "YKPageCell.h"
11 | #import "YKMenuView.h"
12 | @class YKPageView;
13 |
14 | typedef NS_ENUM(NSInteger, YKMenuItemTitleSizeState) {
15 | YKMenuItemTitleSizeStateNormal = 0,
16 | YKMenuItemTitleSizeStateSelected
17 | };
18 |
19 | typedef NS_ENUM(NSInteger, YKMenuItemTitleColorState) {
20 | YKMenuItemTitleColorStateNormal = 0,
21 | YKMenuItemTitleColorStateSelected
22 | };
23 |
24 | /** 数据源 */
25 | @protocol YKPageViewDataSource
26 | @required
27 | /**
28 | * 数据源方法,获取当前 index 的 cell
29 | *
30 | * @param pageView 翻页视图
31 | * @param index cell 的序号
32 | *
33 | * @return YKPageCell
34 | */
35 | - (YKPageCell *)pageView:(YKPageView *)pageView cellForIndex:(NSInteger)index;
36 |
37 | /**
38 | * 数据源方法,获取当前menuView的items标题,以NSArray的形式
39 | *
40 | * @param pageView 翻页视图
41 | *
42 | * @return menuView 的 items 的标题 (内为字符串)
43 | */
44 | - (NSArray *)menuItemsForMenuViewInPageView:(YKPageView *)pageView;
45 |
46 | @end
47 |
48 | /** 代理 */
49 | @protocol YKPageViewDelegate
50 | @optional
51 | /**
52 | * 设置 menuView 的高度,默认为 30
53 | *
54 | * @param pageView 当前翻页视图
55 | * @param menuView 顶部菜单视图
56 | *
57 | * @return menuView 的高度
58 | */
59 | - (CGFloat)pageView:(YKPageView *)pageView heightForMenuView:(YKMenuView *)menuView;
60 |
61 | /**
62 | * 设置menuView的背景颜色
63 | *
64 | * @param pageView 当前翻页视图
65 | *
66 | * @return UIColor
67 | */
68 | - (UIColor *)backgroundColorOfMenuViewInPageView:(YKPageView *)pageView;
69 |
70 | /**
71 | * 设置菜单栏标题颜色
72 | *
73 | * @param pageView 当前翻页视图
74 | * @param state 分为 YKMenuItemTitleColorStateNormal (未选中) / YKMenuItemTitleColorStateSelected (选中)
75 | *
76 | * @return UIColor
77 | */
78 | - (UIColor *)titleColorOfMenuItemInPageView:(YKPageView *)pageView withState:(YKMenuItemTitleColorState)state;
79 |
80 | /**
81 | * 设置菜单栏标题字体大小 (大于零)
82 | *
83 | * @param pageView 当前翻页视图
84 | * @param state 分为 YKMenuItemTitleSizeStateNormal (未选中) / YKMenuItemTitleSizeStateSelected (选中)
85 | *
86 | * @return 标题字体大小
87 | */
88 | - (CGFloat)titleSizeOfMenuItemInPageView:(YKPageView *)pageView withState:(YKMenuItemTitleSizeState)state;
89 |
90 | /**
91 | * 设置菜单栏内部item的宽度,默认宽度为60
92 | *
93 | * @param pageView 当前翻页视图
94 | * @param index YKMenuItem 的序号,可根据序号定制
95 | *
96 | * @return item的宽度
97 | */
98 | - (CGFloat)pageView:(YKPageView *)pageView widthForMenuItemAtIndex:(NSInteger)index;
99 |
100 | @end
101 |
102 | @interface YKPageView : UIView
103 |
104 | /** 点击菜单栏item时翻页的动画,默认为 YES */
105 | @property (nonatomic, assign) BOOL toAnimate;
106 |
107 | /** 上方导航栏的样式 */
108 | @property (nonatomic, assign) YKMenuViewStyle menuViewStyle;
109 | @property (nonatomic, assign) NSInteger selectIndex;
110 | @property (nonatomic, strong) UIColor *progressColor;
111 | @property (nonatomic, weak) id dataSource;
112 | @property (nonatomic, weak) id delegate;
113 |
114 | /** 刷新数据 */
115 | - (void)reloadData;
116 |
117 | /**
118 | * 从缓存池中取出可重用的cell,若没有则返回nil
119 | *
120 | * @param identifier 重用cell的标识符
121 | *
122 | * @return 返回Cell以供重用
123 | */
124 | - (id)dequeueReusableCellWithIdentifier:(NSString *)identifier;
125 |
126 | @end
127 |
--------------------------------------------------------------------------------
/YKPageView/MenuView/YKPageView.m:
--------------------------------------------------------------------------------
1 | //
2 | // YKPageView.m
3 | // YKPageView
4 | //
5 | // Created by Mark on 15/4/27.
6 | // Copyright (c) 2015年 yq. All rights reserved.
7 | //
8 |
9 | #import "YKPageView.h"
10 | #import "YKMenuView.h"
11 |
12 | static CGFloat const YKTitleSizeSelected = 18.0f;
13 | static CGFloat const YKTitleSizeNormol = 15.0f;
14 | static CGFloat const YKMenuViewDefaultHeight = 30.0f;
15 | static CGFloat const YKMenuItemDefaultWidth = 60.0f;
16 |
17 | @interface YKPageView () {
18 | BOOL _animate;
19 | BOOL _setted;
20 | }
21 | @property (nonatomic, weak) UIScrollView *scrollView;
22 | @property (nonatomic, strong) NSMutableSet *reusePool;
23 | @property (nonatomic, assign) CGFloat menuViewHeight;
24 | @property (nonatomic, strong) NSMutableDictionary *displayCells;
25 | @property (nonatomic, strong) NSMutableArray *cellFrames;
26 | @property (nonatomic, weak) YKMenuView *menuView;
27 | @end
28 |
29 | @implementation YKPageView
30 | #pragma mark - Lazy load
31 | - (NSMutableDictionary *)displayCells {
32 | if (_displayCells == nil) {
33 | _displayCells = [[NSMutableDictionary alloc] init];
34 | }
35 | return _displayCells;
36 | }
37 |
38 | - (NSMutableArray *)cellFrames {
39 | if (_cellFrames == nil) {
40 | _cellFrames = [NSMutableArray array];
41 | }
42 | return _cellFrames;
43 | }
44 |
45 | - (NSMutableSet *)reusePool {
46 | if (_reusePool == nil) {
47 | _reusePool = [[NSMutableSet alloc] init];
48 | }
49 | return _reusePool;
50 | }
51 |
52 | - (CGFloat)menuViewHeight {
53 | if (!_menuViewHeight) {
54 | if ([self.delegate respondsToSelector:@selector(pageView:heightForMenuView:)]) {
55 | _menuViewHeight = [self.delegate pageView:self heightForMenuView:self.menuView];
56 | } else {
57 | _menuViewHeight = YKMenuViewDefaultHeight;
58 | }
59 | }
60 | return _menuViewHeight;
61 | }
62 |
63 | - (void)willMoveToSuperview:(UIView *)newSuperview {
64 | [super willMoveToSuperview:newSuperview];
65 | [self reloadData];
66 | }
67 |
68 | // 添加菜单栏
69 | - (void)addMenuView {
70 | CGFloat width = self.frame.size.width;
71 | CGFloat height = self.menuViewHeight;
72 | NSArray *items = [self.dataSource menuItemsForMenuViewInPageView:self];
73 | CGRect frame = CGRectMake(0, 0, width, height);
74 | UIColor *color,*norColor,*selColor;
75 | CGFloat norSize,selSize;
76 | if ([self.delegate respondsToSelector:@selector(backgroundColorOfMenuViewInPageView:)]) {
77 | color = [self.delegate backgroundColorOfMenuViewInPageView:self];
78 | }
79 | if ([self.delegate respondsToSelector:@selector(titleColorOfMenuItemInPageView:withState:)]) {
80 | norColor = [self.delegate titleColorOfMenuItemInPageView:self withState:YKMenuItemTitleColorStateNormal];
81 | selColor = [self.delegate titleColorOfMenuItemInPageView:self withState:YKMenuItemTitleColorStateSelected];
82 | }
83 | if ([self.delegate respondsToSelector:@selector(titleSizeOfMenuItemInPageView:withState:)]) {
84 | norSize = [self.delegate titleSizeOfMenuItemInPageView:self withState:YKMenuItemTitleSizeStateNormal];
85 | selSize = [self.delegate titleSizeOfMenuItemInPageView:self withState:YKMenuItemTitleSizeStateSelected];
86 | } else {
87 | norSize = YKTitleSizeNormol;
88 | selSize = YKTitleSizeSelected;
89 | }
90 | YKMenuView *menuView = [[YKMenuView alloc] initWithFrame:frame buttonItems:items backgroundColor:color norSize:norSize selSize:selSize norColor:norColor selColor:selColor];
91 | menuView.delegate = self;
92 | self.menuView.lineColor = self.progressColor;
93 | switch (self.menuViewStyle) {
94 | case YKMenuViewStyleLine:
95 | menuView.style = YKMenuViewStyleLine;
96 | break;
97 | case YKMenuViewStyleFoold:
98 | menuView.style = YKMenuViewStyleFoold;
99 | break;
100 | case YKMenuViewStyleFooldHollow:
101 | menuView.style = YKMenuViewStyleFooldHollow;
102 | break;
103 | default:
104 | break;
105 | }
106 | [self addSubview:menuView];
107 | self.menuView = menuView;
108 | }
109 |
110 | // 添加主滚动视图
111 | - (void)addScrollView {
112 | CGFloat x = 0;
113 | CGFloat y = self.menuViewHeight;
114 | CGFloat width = self.frame.size.width;
115 | CGFloat height = self.frame.size.height - self.menuViewHeight;
116 | UIScrollView *scrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(x, y, width, height)];
117 | scrollView.showsHorizontalScrollIndicator = NO;
118 | scrollView.showsVerticalScrollIndicator = NO;
119 | scrollView.pagingEnabled = YES;
120 | scrollView.delegate = self;
121 | NSUInteger numOfCells = [[self.dataSource menuItemsForMenuViewInPageView:self] count];
122 | for (int i = 0; i < numOfCells; i++) {
123 | CGFloat x = i * width;
124 | CGFloat y = 0;
125 | CGRect frame = CGRectMake(x, y, width, height);
126 | if (i == 0) {
127 | YKPageCell *cell = [self.dataSource pageView:self cellForIndex:i];
128 | cell.frame = frame;
129 | [scrollView addSubview:cell];
130 |
131 | [self.displayCells setObject:cell forKey:@(i)];
132 | }
133 | [self.cellFrames addObject:[NSValue valueWithCGRect:frame]];
134 | }
135 | CGFloat contentX = self.frame.size.width*numOfCells;
136 | CGFloat contentY = height;
137 | scrollView.contentSize = CGSizeMake(contentX, contentY);
138 | scrollView.bounces = NO;
139 | [self addSubview:scrollView];
140 | self.scrollView = scrollView;
141 | }
142 |
143 | - (BOOL)isInScreen:(CGRect)frame {
144 | CGFloat x = frame.origin.x;
145 | CGFloat ScreenWidth = self.scrollView.frame.size.width;
146 |
147 | CGFloat contentOffsetX = self.scrollView.contentOffset.x;
148 | if (CGRectGetMaxX(frame) > contentOffsetX && x-contentOffsetX < ScreenWidth) {
149 | return YES;
150 | } else {
151 | return NO;
152 | }
153 | }
154 |
155 | // 排列items
156 | - (void)layoutItems {
157 | for (int i = 0; i < self.cellFrames.count; i++) {
158 | YKPageCell *cell = self.displayCells[@(i)];
159 | CGRect frame = [self.cellFrames[i] CGRectValue];
160 | if ([self isInScreen:frame]) {
161 | if (cell == nil) {
162 | // cell不存在时,问数据源要cell
163 | cell = [self.dataSource pageView:self cellForIndex:i];
164 | cell.frame = frame;
165 | [self.scrollView addSubview:cell];
166 | // 放到展示中的数组中,以便取用
167 | [self.displayCells setObject:cell forKey:@(i)];
168 | }
169 | } else {
170 | // cell存在且不在屏幕中
171 | if (cell) {
172 | // 移除屏幕上显示的cell
173 | [self.displayCells removeObjectForKey:@(i)];
174 | [cell removeFromSuperview];
175 | // 放入缓存池
176 | [self.reusePool addObject:cell];
177 | }
178 | }
179 | }
180 | }
181 |
182 | // 清空所有数组,字典,并移除所有子控件
183 | - (void)clearAllData {
184 | [self.scrollView.subviews makeObjectsPerformSelector:@selector(removeFromSuperview)];
185 | [self.displayCells.allValues makeObjectsPerformSelector:@selector(removeFromSuperview)];
186 | [self.displayCells removeAllObjects];
187 | [self.reusePool removeAllObjects];
188 | [self.cellFrames removeAllObjects];
189 | if (self.menuView) {
190 | [self.menuView removeFromSuperview];
191 | }
192 | if (self.scrollView) {
193 | [self.scrollView removeFromSuperview];
194 | }
195 | }
196 |
197 | #pragma mark - Public Methods
198 | - (void)setSelectIndex:(NSInteger)selectIndex {
199 | _selectIndex = selectIndex;
200 | if (self.menuView) {
201 | [self.menuView selectItemAtIndex:selectIndex];
202 | }
203 | }
204 |
205 | - (void)setToAnimate:(BOOL)toAnimate {
206 | _toAnimate = toAnimate;
207 | _setted = YES;
208 | }
209 |
210 | - (void)reloadData {
211 | [self clearAllData];
212 | [self addMenuView];
213 | [self addScrollView];
214 | if (self.selectIndex != 0) {
215 | [self.menuView selectItemAtIndex:self.selectIndex];
216 | }
217 | }
218 |
219 | - (id)dequeueReusableCellWithIdentifier:(NSString *)identifier {
220 | __block YKPageCell *reuseCell;
221 | [self.reusePool enumerateObjectsUsingBlock:^(YKPageCell *cell, BOOL *stop) {
222 | if ([cell.identifier isEqualToString:identifier]) {
223 | reuseCell = cell;
224 | *stop = YES;
225 | }
226 | }];
227 | if (reuseCell) {
228 | [self.reusePool removeObject:reuseCell];
229 | }
230 | return reuseCell;
231 | }
232 |
233 | #pragma mark - MenuView delegate
234 | - (void)menuView:(YKMenuView *)menu didSelesctedIndex:(NSInteger)index currentIndex:(NSInteger)currentIndex {
235 | _animate = NO;
236 | CGPoint targetP = CGPointMake(self.scrollView.frame.size.width*index, 0);
237 | [self.scrollView setContentOffset:targetP animated:(_setted ? self.toAnimate : YES)];
238 | }
239 |
240 | - (CGFloat)menuView:(YKMenuView *)menu widthForItemAtIndex:(NSInteger)index {
241 | if ([self.delegate respondsToSelector:@selector(pageView:widthForMenuItemAtIndex:)]) {
242 | return [self.delegate pageView:self widthForMenuItemAtIndex:index];
243 | } else {
244 | return YKMenuItemDefaultWidth;
245 | }
246 | }
247 |
248 | #pragma mark - ScrollView delegate
249 | - (void)scrollViewDidScroll:(UIScrollView *)scrollView {
250 | [self layoutItems];
251 | if (_animate) {
252 | CGFloat width = scrollView.frame.size.width;
253 | CGFloat contentOffsetX = scrollView.contentOffset.x;
254 |
255 | CGFloat rate = contentOffsetX / width;
256 | [self.menuView slideMenuAtProgress:rate];
257 | }
258 | }
259 |
260 | - (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView {
261 | _animate = YES;
262 | }
263 |
264 | @end
265 |
--------------------------------------------------------------------------------
/YKPageView/MenuView/YKProgressView.h:
--------------------------------------------------------------------------------
1 | //
2 | // YKProgressView.h
3 | // YKPageView
4 | //
5 | // Created by Mark on 15/6/20.
6 | // Copyright (c) 2015年 yq. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface YKProgressView : UIView
12 | @property (nonatomic, strong) NSArray *itemFrames;
13 | @property (nonatomic, assign) CGColorRef color;
14 | @property (nonatomic, assign) CGFloat progress;
15 |
16 | - (void)setProgressWithOutAnimate:(CGFloat)progress;
17 | @end
18 |
--------------------------------------------------------------------------------
/YKPageView/MenuView/YKProgressView.m:
--------------------------------------------------------------------------------
1 | //
2 | // YKProgressView.m
3 | // YKPageView
4 | //
5 | // Created by Mark on 15/6/20.
6 | // Copyright (c) 2015年 yq. All rights reserved.
7 | //
8 |
9 | #import "YKProgressView.h"
10 | @implementation YKProgressView {
11 | int sign;
12 | CGFloat gap;
13 | CGFloat step;
14 | __weak CADisplayLink *_link;
15 | }
16 |
17 | - (void)setProgressWithOutAnimate:(CGFloat)progress {
18 | if (self.progress == progress) return;
19 | _progress = progress;
20 | [self setNeedsDisplay];
21 | }
22 |
23 | - (void)setProgress:(CGFloat)progress {
24 | if (self.progress == progress) return;
25 | if (fabs(progress - _progress) >= 0.94 /*&& fabs(progress - _progress) < 1.2*/) {
26 | gap = fabs(self.progress - progress);
27 | sign = self.progress > progress ? -1 : 1;
28 | step = gap / 20.0;
29 | CADisplayLink *link = [CADisplayLink displayLinkWithTarget:self selector:@selector(progressChanged)];
30 | [link addToRunLoop:[NSRunLoop mainRunLoop] forMode:NSRunLoopCommonModes];
31 | _link = link;
32 | return;
33 | }
34 | _progress = progress;
35 | [self setNeedsDisplay];
36 | }
37 |
38 | - (void)progressChanged {
39 | if (gap >= 0.0) {
40 | self.progress += sign * step;
41 | gap -= step;
42 | } else {
43 | self.progress = (int)(self.progress + 0.5);
44 | [_link invalidate];
45 | _link = nil;
46 | }
47 | }
48 |
49 | - (void)drawRect:(CGRect)rect {
50 | // Drawing code
51 | [super drawRect:rect];
52 | CGContextRef ctx = UIGraphicsGetCurrentContext();
53 | int index = (int)self.progress;
54 | CGFloat rate = self.progress - index;
55 | CGRect currentFrame = [self.itemFrames[index] CGRectValue];
56 | CGFloat currentWidth = currentFrame.size.width;
57 | int nextIndex = index + 1 < self.itemFrames.count ? index + 1 : index;
58 | CGFloat nextWidth = [self.itemFrames[nextIndex] CGRectValue].size.width;
59 | CGFloat height = self.frame.size.height;
60 | CGFloat constY = height / 2;
61 | CGFloat currentX = currentFrame.origin.x;
62 | CGFloat nextX = [self.itemFrames[nextIndex] CGRectValue].origin.x;
63 | CGFloat startX = currentX + (nextX - currentX) * rate;
64 | CGFloat endX = startX + currentWidth + (nextWidth - currentWidth)*rate;
65 | CGContextMoveToPoint(ctx, startX, constY);
66 | CGContextAddLineToPoint(ctx, endX, constY);
67 | CGContextSetLineWidth(ctx, height);
68 | CGContextSetStrokeColorWithColor(ctx, self.color);
69 | CGContextStrokePath(ctx);
70 | }
71 |
72 | @end
73 |
--------------------------------------------------------------------------------
/YKPageView/ScreenShot/CosChat.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wangmchn/YKPageView/a008f2d686dd817ce9b1332ac5a79d5bc5866c44/YKPageView/ScreenShot/CosChat.gif
--------------------------------------------------------------------------------
/YKPageView/ScreenShot/ScreenShot.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wangmchn/YKPageView/a008f2d686dd817ce9b1332ac5a79d5bc5866c44/YKPageView/ScreenShot/ScreenShot.gif
--------------------------------------------------------------------------------
/YKPageView/UIColor+Random.h:
--------------------------------------------------------------------------------
1 | //
2 | // UIColor+Random.h
3 | // test
4 | //
5 | // Created by Mark on 15/4/28.
6 | // Copyright (c) 2015年 yq. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface UIColor (Random)
12 | + (UIColor *)randomColor;
13 | @end
14 |
--------------------------------------------------------------------------------
/YKPageView/UIColor+Random.m:
--------------------------------------------------------------------------------
1 | //
2 | // UIColor+Random.m
3 | // test
4 | //
5 | // Created by Mark on 15/4/28.
6 | // Copyright (c) 2015年 yq. All rights reserved.
7 | //
8 |
9 | #import "UIColor+Random.h"
10 |
11 | @implementation UIColor (Random)
12 |
13 | + (UIColor *)randomColor{
14 | CGFloat r = arc4random_uniform(255);
15 | CGFloat g = arc4random_uniform(255);
16 | CGFloat b = arc4random_uniform(255);
17 | return [UIColor colorWithRed:r/255.0 green:g/255.0 blue:b/255.0 alpha:1];
18 | }
19 |
20 | @end
21 |
--------------------------------------------------------------------------------
/YKPageView/ViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // ViewController.h
3 | // YKPageView
4 | //
5 | // Created by Mark on 15/5/30.
6 | // Copyright (c) 2015年 yq. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface ViewController : UIViewController
12 |
13 |
14 | @end
15 |
16 |
--------------------------------------------------------------------------------
/YKPageView/ViewController.m:
--------------------------------------------------------------------------------
1 | //
2 | // ViewController.m
3 | // YKPageView
4 | //
5 | // Created by Mark on 15/5/30.
6 | // Copyright (c) 2015年 yq. All rights reserved.
7 | //
8 |
9 | #import "ViewController.h"
10 | #import "YKPageView.h"
11 | #import "UIColor+Random.h"
12 |
13 | @interface ViewController ()
14 | @property (nonatomic, strong) NSArray *items;
15 | @property (nonatomic, weak) YKPageView *pageView;
16 | @end
17 |
18 | @implementation ViewController
19 | - (NSArray *)items {
20 | if (_items == nil) {
21 | _items = @[@"最新", @"言情", @"武侠", @"明星", @"DotA", @"LOL", @"WOW", @"高富帅", @"富美", @"屌丝", @"壮汉"];
22 | }
23 | return _items;
24 | }
25 |
26 | - (void)viewDidLoad {
27 | [super viewDidLoad];
28 | // Do any additional setup after loading the view, typically from a nib.
29 | self.title = @"测试";
30 | self.view.backgroundColor = [UIColor whiteColor];
31 | self.edgesForExtendedLayout = UIRectEdgeNone;
32 |
33 | [self p_addPageView];
34 | }
35 |
36 | - (void)p_addPageView {
37 | YKPageView *pageView = [[YKPageView alloc] initWithFrame:self.view.bounds];
38 | pageView.dataSource = self;
39 | pageView.delegate = self;
40 | pageView.selectIndex = 3;
41 | pageView.menuViewStyle = YKMenuViewStyleLine;
42 | [self.view addSubview:pageView];
43 | self.pageView = pageView;
44 | }
45 |
46 | #pragma mark - page view datasource
47 | // Menu的标题用NSArray封装,内为NSString
48 | - (NSArray *)menuItemsForMenuViewInPageView:(YKPageView *)pageView {
49 | return self.items;
50 | }
51 |
52 | - (YKPageCell *)pageView:(YKPageView *)pageView cellForIndex:(NSInteger)index {
53 | static NSString *identifier = @"pageCell";
54 | YKPageCell *cell = [pageView dequeueReusableCellWithIdentifier:identifier];
55 | if (cell == nil) {
56 | cell = [[YKPageCell alloc] initWithIdentifier:identifier];
57 | }
58 | cell.backgroundColor = [UIColor randomColor];
59 | return cell;
60 | }
61 |
62 | #pragma mark Page view delegate
63 | // 若不实现,默认红黑,为保证字体颜色渐变,请尽量选用RGBA来创建UIColor
64 | - (UIColor *)titleColorOfMenuItemInPageView:(YKPageView *)pageView withState:(YKMenuItemTitleColorState)state {
65 | return [UIColor randomColor];
66 | }
67 |
68 | // 若不实现,默认为30
69 | - (CGFloat)pageView:(YKPageView *)pageView heightForMenuView:(YKMenuView *)menuView{
70 | return 30;
71 | }
72 |
73 | // 若不实现,默认为15/18
74 | - (CGFloat)titleSizeOfMenuItemInPageView:(YKPageView *)pageView withState:(YKMenuItemTitleSizeState)state {
75 | switch (state) {
76 | case YKMenuItemTitleSizeStateNormal:
77 | return 15;
78 | break;
79 | case YKMenuItemTitleSizeStateSelected:
80 | return 18;
81 | default:
82 | break;
83 | }
84 | }
85 |
86 | // 若不实现,默认为灰色
87 | - (UIColor *)backgroundColorOfMenuViewInPageView:(YKPageView *)pageView {
88 | return [UIColor lightGrayColor];
89 | }
90 |
91 | // MenuView 内部各个 item 的宽度,若标题过长可自行设置,默认为 60
92 | - (CGFloat)pageView:(YKPageView *)pageView widthForMenuItemAtIndex:(NSInteger)index {
93 | return 60;
94 | }
95 |
96 | @end
--------------------------------------------------------------------------------
/YKPageView/main.m:
--------------------------------------------------------------------------------
1 | //
2 | // main.m
3 | // YKPageView
4 | //
5 | // Created by Mark on 15/5/30.
6 | // Copyright (c) 2015年 yq. All rights reserved.
7 | //
8 |
9 | #import
10 | #import "AppDelegate.h"
11 |
12 | int main(int argc, char * argv[]) {
13 | @autoreleasepool {
14 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/YKPageViewTests/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIdentifier
10 | Shellv.$(PRODUCT_NAME:rfc1034identifier)
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundleName
14 | $(PRODUCT_NAME)
15 | CFBundlePackageType
16 | BNDL
17 | CFBundleShortVersionString
18 | 1.0
19 | CFBundleSignature
20 | ????
21 | CFBundleVersion
22 | 1
23 |
24 |
25 |
--------------------------------------------------------------------------------
/YKPageViewTests/YKPageViewTests.m:
--------------------------------------------------------------------------------
1 | //
2 | // YKPageViewTests.m
3 | // YKPageViewTests
4 | //
5 | // Created by Mark on 15/5/30.
6 | // Copyright (c) 2015年 yq. All rights reserved.
7 | //
8 |
9 | #import
10 | #import
11 |
12 | @interface YKPageViewTests : XCTestCase
13 |
14 | @end
15 |
16 | @implementation YKPageViewTests
17 |
18 | - (void)setUp {
19 | [super setUp];
20 | // Put setup code here. This method is called before the invocation of each test method in the class.
21 | }
22 |
23 | - (void)tearDown {
24 | // Put teardown code here. This method is called after the invocation of each test method in the class.
25 | [super tearDown];
26 | }
27 |
28 | - (void)testExample {
29 | // This is an example of a functional test case.
30 | XCTAssert(YES, @"Pass");
31 | }
32 |
33 | - (void)testPerformanceExample {
34 | // This is an example of a performance test case.
35 | [self measureBlock:^{
36 | // Put the code you want to measure the time of here.
37 | }];
38 | }
39 |
40 | @end
41 |
--------------------------------------------------------------------------------