├── README.md ├── Untitled.gif ├── YXCustomIndexView.xcodeproj ├── project.pbxproj ├── project.xcworkspace │ ├── contents.xcworkspacedata │ └── xcuserdata │ │ └── GeekWorld.xcuserdatad │ │ └── UserInterfaceState.xcuserstate └── xcuserdata │ └── GeekWorld.xcuserdatad │ ├── xcdebugger │ └── Breakpoints_v2.xcbkptlist │ └── xcschemes │ ├── TBIndexView.xcscheme │ └── xcschememanagement.plist └── YXCustomIndexView ├── AppDelegate.h ├── AppDelegate.m ├── Assets.xcassets └── AppIcon.appiconset │ └── Contents.json ├── Base.lproj ├── LaunchScreen.storyboard └── Main.storyboard ├── Info.plist ├── NSString+RN.h ├── NSString+RN.m ├── ViewController.h ├── ViewController.m ├── YXTableViewIndexView ├── .svn │ ├── entries │ └── text-base │ │ ├── TableViewIndexView.h.svn-base │ │ ├── TableViewIndexView.m.svn-base │ │ └── TableViewIndexView.xib.svn-base ├── YXTableViewIndexView.h ├── YXTableViewIndexView.m └── YXTableViewIndexView.xib └── main.m /README.md: -------------------------------------------------------------------------------- 1 | # YXCustomIndexView 2 | 3 | 1,自定义YXTableViewIndexView索引,固定宽度20,这个可以调整,高度就根据有多少个索引字符来计算,当传入一个索引字符数组的时候就刷新这个视图,显示出索引字符, 4 | 5 | 2,在YXTableViewIndexView中添加一个提示索引的放大浮动View,位置相对于UITableView的中心位置,这个根据需求调整。 6 | 7 | 3,YXTableViewIndexView添加点击和拖拽手势,当手指在YXTableViewIndexView上滑动和点击时显示浮动VIew,并显示当前索引字符,手势完成时影藏浮动View。 8 | 9 | 效果: 10 | 11 | ![image](https://github.com/zhangYongXu/YXCustomIndexView/blob/master/Untitled.gif) 12 | -------------------------------------------------------------------------------- /Untitled.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhangYongXu/YXCustomIndexView/abd192a6b8b155056e9c4f40e9a6872d8086db4d/Untitled.gif -------------------------------------------------------------------------------- /YXCustomIndexView.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | F17C9D721F0F7F800006D024 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = F17C9D5A1F0F7F800006D024 /* AppDelegate.m */; }; 11 | F17C9D741F0F7F800006D024 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = F17C9D5E1F0F7F800006D024 /* Assets.xcassets */; }; 12 | F17C9D751F0F7F800006D024 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = F17C9D5F1F0F7F800006D024 /* LaunchScreen.storyboard */; }; 13 | F17C9D761F0F7F800006D024 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = F17C9D611F0F7F800006D024 /* Main.storyboard */; }; 14 | F17C9D771F0F7F800006D024 /* Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = F17C9D631F0F7F800006D024 /* Info.plist */; }; 15 | F17C9D781F0F7F800006D024 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = F17C9D641F0F7F800006D024 /* main.m */; }; 16 | F17C9D791F0F7F800006D024 /* NSString+RN.m in Sources */ = {isa = PBXBuildFile; fileRef = F17C9D661F0F7F800006D024 /* NSString+RN.m */; }; 17 | F17C9D7B1F0F7F800006D024 /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = F17C9D6A1F0F7F800006D024 /* ViewController.m */; }; 18 | F17C9D7C1F0F7F800006D024 /* YXTableViewIndexView.m in Sources */ = {isa = PBXBuildFile; fileRef = F17C9D6D1F0F7F800006D024 /* YXTableViewIndexView.m */; }; 19 | F17C9D7D1F0F7F800006D024 /* YXTableViewIndexView.xib in Resources */ = {isa = PBXBuildFile; fileRef = F17C9D6E1F0F7F800006D024 /* YXTableViewIndexView.xib */; }; 20 | /* End PBXBuildFile section */ 21 | 22 | /* Begin PBXContainerItemProxy section */ 23 | F17058B21F0B88B000D0C6BB /* PBXContainerItemProxy */ = { 24 | isa = PBXContainerItemProxy; 25 | containerPortal = F17058901F0B88B000D0C6BB /* Project object */; 26 | proxyType = 1; 27 | remoteGlobalIDString = F17058971F0B88B000D0C6BB; 28 | remoteInfo = TBIndexView; 29 | }; 30 | /* End PBXContainerItemProxy section */ 31 | 32 | /* Begin PBXFileReference section */ 33 | F17058981F0B88B000D0C6BB /* YXCustomIndexView.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = YXCustomIndexView.app; sourceTree = BUILT_PRODUCTS_DIR; }; 34 | F17058B11F0B88B000D0C6BB /* YXCustomIndexViewUITests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = YXCustomIndexViewUITests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 35 | F17C9D591F0F7F800006D024 /* AppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; 36 | F17C9D5A1F0F7F800006D024 /* AppDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; 37 | F17C9D5E1F0F7F800006D024 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 38 | F17C9D601F0F7F800006D024 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 39 | F17C9D621F0F7F800006D024 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 40 | F17C9D631F0F7F800006D024 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 41 | F17C9D641F0F7F800006D024 /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 42 | F17C9D651F0F7F800006D024 /* NSString+RN.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSString+RN.h"; sourceTree = ""; }; 43 | F17C9D661F0F7F800006D024 /* NSString+RN.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSString+RN.m"; sourceTree = ""; }; 44 | F17C9D691F0F7F800006D024 /* ViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = ""; }; 45 | F17C9D6A1F0F7F800006D024 /* ViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = ""; }; 46 | F17C9D6C1F0F7F800006D024 /* YXTableViewIndexView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = YXTableViewIndexView.h; sourceTree = ""; }; 47 | F17C9D6D1F0F7F800006D024 /* YXTableViewIndexView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = YXTableViewIndexView.m; sourceTree = ""; }; 48 | F17C9D6E1F0F7F800006D024 /* YXTableViewIndexView.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = YXTableViewIndexView.xib; sourceTree = ""; }; 49 | /* End PBXFileReference section */ 50 | 51 | /* Begin PBXFrameworksBuildPhase section */ 52 | F17058951F0B88B000D0C6BB /* Frameworks */ = { 53 | isa = PBXFrameworksBuildPhase; 54 | buildActionMask = 2147483647; 55 | files = ( 56 | ); 57 | runOnlyForDeploymentPostprocessing = 0; 58 | }; 59 | F17058AE1F0B88B000D0C6BB /* Frameworks */ = { 60 | isa = PBXFrameworksBuildPhase; 61 | buildActionMask = 2147483647; 62 | files = ( 63 | ); 64 | runOnlyForDeploymentPostprocessing = 0; 65 | }; 66 | /* End PBXFrameworksBuildPhase section */ 67 | 68 | /* Begin PBXGroup section */ 69 | F170588F1F0B88B000D0C6BB = { 70 | isa = PBXGroup; 71 | children = ( 72 | F17C9D581F0F7F800006D024 /* YXCustomIndexView */, 73 | F17058991F0B88B000D0C6BB /* Products */, 74 | ); 75 | sourceTree = ""; 76 | }; 77 | F17058991F0B88B000D0C6BB /* Products */ = { 78 | isa = PBXGroup; 79 | children = ( 80 | F17058981F0B88B000D0C6BB /* YXCustomIndexView.app */, 81 | F17058B11F0B88B000D0C6BB /* YXCustomIndexViewUITests.xctest */, 82 | ); 83 | name = Products; 84 | sourceTree = ""; 85 | }; 86 | F17C9D581F0F7F800006D024 /* YXCustomIndexView */ = { 87 | isa = PBXGroup; 88 | children = ( 89 | F17C9D6B1F0F7F800006D024 /* YXTableViewIndexView */, 90 | F17C9D591F0F7F800006D024 /* AppDelegate.h */, 91 | F17C9D5A1F0F7F800006D024 /* AppDelegate.m */, 92 | F17C9D651F0F7F800006D024 /* NSString+RN.h */, 93 | F17C9D661F0F7F800006D024 /* NSString+RN.m */, 94 | F17C9D691F0F7F800006D024 /* ViewController.h */, 95 | F17C9D6A1F0F7F800006D024 /* ViewController.m */, 96 | F17C9D5E1F0F7F800006D024 /* Assets.xcassets */, 97 | F17C9D5F1F0F7F800006D024 /* LaunchScreen.storyboard */, 98 | F17C9D611F0F7F800006D024 /* Main.storyboard */, 99 | F17C9D631F0F7F800006D024 /* Info.plist */, 100 | F17C9D641F0F7F800006D024 /* main.m */, 101 | ); 102 | path = YXCustomIndexView; 103 | sourceTree = ""; 104 | }; 105 | F17C9D6B1F0F7F800006D024 /* YXTableViewIndexView */ = { 106 | isa = PBXGroup; 107 | children = ( 108 | F17C9D6C1F0F7F800006D024 /* YXTableViewIndexView.h */, 109 | F17C9D6D1F0F7F800006D024 /* YXTableViewIndexView.m */, 110 | F17C9D6E1F0F7F800006D024 /* YXTableViewIndexView.xib */, 111 | ); 112 | path = YXTableViewIndexView; 113 | sourceTree = ""; 114 | }; 115 | /* End PBXGroup section */ 116 | 117 | /* Begin PBXNativeTarget section */ 118 | F17058971F0B88B000D0C6BB /* YXCustomIndexView */ = { 119 | isa = PBXNativeTarget; 120 | buildConfigurationList = F17058BA1F0B88B000D0C6BB /* Build configuration list for PBXNativeTarget "YXCustomIndexView" */; 121 | buildPhases = ( 122 | F17058941F0B88B000D0C6BB /* Sources */, 123 | F17058951F0B88B000D0C6BB /* Frameworks */, 124 | F17058961F0B88B000D0C6BB /* Resources */, 125 | ); 126 | buildRules = ( 127 | ); 128 | dependencies = ( 129 | ); 130 | name = YXCustomIndexView; 131 | productName = TBIndexView; 132 | productReference = F17058981F0B88B000D0C6BB /* YXCustomIndexView.app */; 133 | productType = "com.apple.product-type.application"; 134 | }; 135 | F17058B01F0B88B000D0C6BB /* YXCustomIndexViewUITests */ = { 136 | isa = PBXNativeTarget; 137 | buildConfigurationList = F17058BD1F0B88B000D0C6BB /* Build configuration list for PBXNativeTarget "YXCustomIndexViewUITests" */; 138 | buildPhases = ( 139 | F17058AD1F0B88B000D0C6BB /* Sources */, 140 | F17058AE1F0B88B000D0C6BB /* Frameworks */, 141 | F17058AF1F0B88B000D0C6BB /* Resources */, 142 | ); 143 | buildRules = ( 144 | ); 145 | dependencies = ( 146 | F17058B31F0B88B000D0C6BB /* PBXTargetDependency */, 147 | ); 148 | name = YXCustomIndexViewUITests; 149 | productName = TBIndexViewUITests; 150 | productReference = F17058B11F0B88B000D0C6BB /* YXCustomIndexViewUITests.xctest */; 151 | productType = "com.apple.product-type.bundle.ui-testing"; 152 | }; 153 | /* End PBXNativeTarget section */ 154 | 155 | /* Begin PBXProject section */ 156 | F17058901F0B88B000D0C6BB /* Project object */ = { 157 | isa = PBXProject; 158 | attributes = { 159 | LastUpgradeCheck = 0830; 160 | ORGANIZATIONNAME = "极客天地"; 161 | TargetAttributes = { 162 | F17058971F0B88B000D0C6BB = { 163 | CreatedOnToolsVersion = 8.3.2; 164 | DevelopmentTeam = PYKU93R6EC; 165 | ProvisioningStyle = Manual; 166 | }; 167 | F17058B01F0B88B000D0C6BB = { 168 | CreatedOnToolsVersion = 8.3.2; 169 | ProvisioningStyle = Automatic; 170 | TestTargetID = F17058971F0B88B000D0C6BB; 171 | }; 172 | }; 173 | }; 174 | buildConfigurationList = F17058931F0B88B000D0C6BB /* Build configuration list for PBXProject "YXCustomIndexView" */; 175 | compatibilityVersion = "Xcode 3.2"; 176 | developmentRegion = English; 177 | hasScannedForEncodings = 0; 178 | knownRegions = ( 179 | en, 180 | Base, 181 | ); 182 | mainGroup = F170588F1F0B88B000D0C6BB; 183 | productRefGroup = F17058991F0B88B000D0C6BB /* Products */; 184 | projectDirPath = ""; 185 | projectRoot = ""; 186 | targets = ( 187 | F17058971F0B88B000D0C6BB /* YXCustomIndexView */, 188 | F17058B01F0B88B000D0C6BB /* YXCustomIndexViewUITests */, 189 | ); 190 | }; 191 | /* End PBXProject section */ 192 | 193 | /* Begin PBXResourcesBuildPhase section */ 194 | F17058961F0B88B000D0C6BB /* Resources */ = { 195 | isa = PBXResourcesBuildPhase; 196 | buildActionMask = 2147483647; 197 | files = ( 198 | F17C9D771F0F7F800006D024 /* Info.plist in Resources */, 199 | F17C9D761F0F7F800006D024 /* Main.storyboard in Resources */, 200 | F17C9D741F0F7F800006D024 /* Assets.xcassets in Resources */, 201 | F17C9D751F0F7F800006D024 /* LaunchScreen.storyboard in Resources */, 202 | F17C9D7D1F0F7F800006D024 /* YXTableViewIndexView.xib in Resources */, 203 | ); 204 | runOnlyForDeploymentPostprocessing = 0; 205 | }; 206 | F17058AF1F0B88B000D0C6BB /* Resources */ = { 207 | isa = PBXResourcesBuildPhase; 208 | buildActionMask = 2147483647; 209 | files = ( 210 | ); 211 | runOnlyForDeploymentPostprocessing = 0; 212 | }; 213 | /* End PBXResourcesBuildPhase section */ 214 | 215 | /* Begin PBXSourcesBuildPhase section */ 216 | F17058941F0B88B000D0C6BB /* Sources */ = { 217 | isa = PBXSourcesBuildPhase; 218 | buildActionMask = 2147483647; 219 | files = ( 220 | F17C9D7C1F0F7F800006D024 /* YXTableViewIndexView.m in Sources */, 221 | F17C9D7B1F0F7F800006D024 /* ViewController.m in Sources */, 222 | F17C9D721F0F7F800006D024 /* AppDelegate.m in Sources */, 223 | F17C9D781F0F7F800006D024 /* main.m in Sources */, 224 | F17C9D791F0F7F800006D024 /* NSString+RN.m in Sources */, 225 | ); 226 | runOnlyForDeploymentPostprocessing = 0; 227 | }; 228 | F17058AD1F0B88B000D0C6BB /* Sources */ = { 229 | isa = PBXSourcesBuildPhase; 230 | buildActionMask = 2147483647; 231 | files = ( 232 | ); 233 | runOnlyForDeploymentPostprocessing = 0; 234 | }; 235 | /* End PBXSourcesBuildPhase section */ 236 | 237 | /* Begin PBXTargetDependency section */ 238 | F17058B31F0B88B000D0C6BB /* PBXTargetDependency */ = { 239 | isa = PBXTargetDependency; 240 | target = F17058971F0B88B000D0C6BB /* YXCustomIndexView */; 241 | targetProxy = F17058B21F0B88B000D0C6BB /* PBXContainerItemProxy */; 242 | }; 243 | /* End PBXTargetDependency section */ 244 | 245 | /* Begin PBXVariantGroup section */ 246 | F17C9D5F1F0F7F800006D024 /* LaunchScreen.storyboard */ = { 247 | isa = PBXVariantGroup; 248 | children = ( 249 | F17C9D601F0F7F800006D024 /* Base */, 250 | ); 251 | name = LaunchScreen.storyboard; 252 | sourceTree = ""; 253 | }; 254 | F17C9D611F0F7F800006D024 /* Main.storyboard */ = { 255 | isa = PBXVariantGroup; 256 | children = ( 257 | F17C9D621F0F7F800006D024 /* Base */, 258 | ); 259 | name = Main.storyboard; 260 | sourceTree = ""; 261 | }; 262 | /* End PBXVariantGroup section */ 263 | 264 | /* Begin XCBuildConfiguration section */ 265 | F17058B81F0B88B000D0C6BB /* Debug */ = { 266 | isa = XCBuildConfiguration; 267 | buildSettings = { 268 | ALWAYS_SEARCH_USER_PATHS = NO; 269 | CLANG_ANALYZER_NONNULL = YES; 270 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 271 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 272 | CLANG_CXX_LIBRARY = "libc++"; 273 | CLANG_ENABLE_MODULES = YES; 274 | CLANG_ENABLE_OBJC_ARC = YES; 275 | CLANG_WARN_BOOL_CONVERSION = YES; 276 | CLANG_WARN_CONSTANT_CONVERSION = YES; 277 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 278 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 279 | CLANG_WARN_EMPTY_BODY = YES; 280 | CLANG_WARN_ENUM_CONVERSION = YES; 281 | CLANG_WARN_INFINITE_RECURSION = YES; 282 | CLANG_WARN_INT_CONVERSION = YES; 283 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 284 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 285 | CLANG_WARN_UNREACHABLE_CODE = YES; 286 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 287 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 288 | COPY_PHASE_STRIP = NO; 289 | DEBUG_INFORMATION_FORMAT = dwarf; 290 | ENABLE_STRICT_OBJC_MSGSEND = YES; 291 | ENABLE_TESTABILITY = YES; 292 | GCC_C_LANGUAGE_STANDARD = gnu99; 293 | GCC_DYNAMIC_NO_PIC = NO; 294 | GCC_NO_COMMON_BLOCKS = YES; 295 | GCC_OPTIMIZATION_LEVEL = 0; 296 | GCC_PREPROCESSOR_DEFINITIONS = ( 297 | "DEBUG=1", 298 | "$(inherited)", 299 | ); 300 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 301 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 302 | GCC_WARN_UNDECLARED_SELECTOR = YES; 303 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 304 | GCC_WARN_UNUSED_FUNCTION = YES; 305 | GCC_WARN_UNUSED_VARIABLE = YES; 306 | IPHONEOS_DEPLOYMENT_TARGET = 10.3; 307 | MTL_ENABLE_DEBUG_INFO = YES; 308 | ONLY_ACTIVE_ARCH = YES; 309 | SDKROOT = iphoneos; 310 | TARGETED_DEVICE_FAMILY = "1,2"; 311 | }; 312 | name = Debug; 313 | }; 314 | F17058B91F0B88B000D0C6BB /* Release */ = { 315 | isa = XCBuildConfiguration; 316 | buildSettings = { 317 | ALWAYS_SEARCH_USER_PATHS = NO; 318 | CLANG_ANALYZER_NONNULL = YES; 319 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 320 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 321 | CLANG_CXX_LIBRARY = "libc++"; 322 | CLANG_ENABLE_MODULES = YES; 323 | CLANG_ENABLE_OBJC_ARC = YES; 324 | CLANG_WARN_BOOL_CONVERSION = YES; 325 | CLANG_WARN_CONSTANT_CONVERSION = YES; 326 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 327 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 328 | CLANG_WARN_EMPTY_BODY = YES; 329 | CLANG_WARN_ENUM_CONVERSION = YES; 330 | CLANG_WARN_INFINITE_RECURSION = YES; 331 | CLANG_WARN_INT_CONVERSION = YES; 332 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 333 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 334 | CLANG_WARN_UNREACHABLE_CODE = YES; 335 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 336 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 337 | COPY_PHASE_STRIP = NO; 338 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 339 | ENABLE_NS_ASSERTIONS = NO; 340 | ENABLE_STRICT_OBJC_MSGSEND = YES; 341 | GCC_C_LANGUAGE_STANDARD = gnu99; 342 | GCC_NO_COMMON_BLOCKS = YES; 343 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 344 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 345 | GCC_WARN_UNDECLARED_SELECTOR = YES; 346 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 347 | GCC_WARN_UNUSED_FUNCTION = YES; 348 | GCC_WARN_UNUSED_VARIABLE = YES; 349 | IPHONEOS_DEPLOYMENT_TARGET = 10.3; 350 | MTL_ENABLE_DEBUG_INFO = NO; 351 | SDKROOT = iphoneos; 352 | TARGETED_DEVICE_FAMILY = "1,2"; 353 | VALIDATE_PRODUCT = YES; 354 | }; 355 | name = Release; 356 | }; 357 | F17058BB1F0B88B000D0C6BB /* Debug */ = { 358 | isa = XCBuildConfiguration; 359 | buildSettings = { 360 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 361 | DEVELOPMENT_TEAM = PYKU93R6EC; 362 | INFOPLIST_FILE = YXCustomIndexView/Info.plist; 363 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 364 | PRODUCT_BUNDLE_IDENTIFIER = com.commonTestID.YXCustomIndexView; 365 | PRODUCT_NAME = "$(TARGET_NAME)"; 366 | PROVISIONING_PROFILE = "31c99898-0c3f-41a9-ad7e-d9019a33cfb8"; 367 | PROVISIONING_PROFILE_SPECIFIER = commonTestID_development; 368 | }; 369 | name = Debug; 370 | }; 371 | F17058BC1F0B88B000D0C6BB /* Release */ = { 372 | isa = XCBuildConfiguration; 373 | buildSettings = { 374 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 375 | DEVELOPMENT_TEAM = PYKU93R6EC; 376 | INFOPLIST_FILE = YXCustomIndexView/Info.plist; 377 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 378 | PRODUCT_BUNDLE_IDENTIFIER = com.commonTestID.YXCustomIndexView; 379 | PRODUCT_NAME = "$(TARGET_NAME)"; 380 | PROVISIONING_PROFILE = "31c99898-0c3f-41a9-ad7e-d9019a33cfb8"; 381 | PROVISIONING_PROFILE_SPECIFIER = commonTestID_development; 382 | }; 383 | name = Release; 384 | }; 385 | F17058BE1F0B88B000D0C6BB /* Debug */ = { 386 | isa = XCBuildConfiguration; 387 | buildSettings = { 388 | INFOPLIST_FILE = TBIndexViewUITests/Info.plist; 389 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 390 | PRODUCT_BUNDLE_IDENTIFIER = com.geekworld.TBIndexViewUITests; 391 | PRODUCT_NAME = "$(TARGET_NAME)"; 392 | TEST_TARGET_NAME = TBIndexView; 393 | }; 394 | name = Debug; 395 | }; 396 | F17058BF1F0B88B000D0C6BB /* Release */ = { 397 | isa = XCBuildConfiguration; 398 | buildSettings = { 399 | INFOPLIST_FILE = TBIndexViewUITests/Info.plist; 400 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 401 | PRODUCT_BUNDLE_IDENTIFIER = com.geekworld.TBIndexViewUITests; 402 | PRODUCT_NAME = "$(TARGET_NAME)"; 403 | TEST_TARGET_NAME = TBIndexView; 404 | }; 405 | name = Release; 406 | }; 407 | /* End XCBuildConfiguration section */ 408 | 409 | /* Begin XCConfigurationList section */ 410 | F17058931F0B88B000D0C6BB /* Build configuration list for PBXProject "YXCustomIndexView" */ = { 411 | isa = XCConfigurationList; 412 | buildConfigurations = ( 413 | F17058B81F0B88B000D0C6BB /* Debug */, 414 | F17058B91F0B88B000D0C6BB /* Release */, 415 | ); 416 | defaultConfigurationIsVisible = 0; 417 | defaultConfigurationName = Release; 418 | }; 419 | F17058BA1F0B88B000D0C6BB /* Build configuration list for PBXNativeTarget "YXCustomIndexView" */ = { 420 | isa = XCConfigurationList; 421 | buildConfigurations = ( 422 | F17058BB1F0B88B000D0C6BB /* Debug */, 423 | F17058BC1F0B88B000D0C6BB /* Release */, 424 | ); 425 | defaultConfigurationIsVisible = 0; 426 | defaultConfigurationName = Release; 427 | }; 428 | F17058BD1F0B88B000D0C6BB /* Build configuration list for PBXNativeTarget "YXCustomIndexViewUITests" */ = { 429 | isa = XCConfigurationList; 430 | buildConfigurations = ( 431 | F17058BE1F0B88B000D0C6BB /* Debug */, 432 | F17058BF1F0B88B000D0C6BB /* Release */, 433 | ); 434 | defaultConfigurationIsVisible = 0; 435 | defaultConfigurationName = Release; 436 | }; 437 | /* End XCConfigurationList section */ 438 | }; 439 | rootObject = F17058901F0B88B000D0C6BB /* Project object */; 440 | } 441 | -------------------------------------------------------------------------------- /YXCustomIndexView.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /YXCustomIndexView.xcodeproj/project.xcworkspace/xcuserdata/GeekWorld.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhangYongXu/YXCustomIndexView/abd192a6b8b155056e9c4f40e9a6872d8086db4d/YXCustomIndexView.xcodeproj/project.xcworkspace/xcuserdata/GeekWorld.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /YXCustomIndexView.xcodeproj/xcuserdata/GeekWorld.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | -------------------------------------------------------------------------------- /YXCustomIndexView.xcodeproj/xcuserdata/GeekWorld.xcuserdatad/xcschemes/TBIndexView.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 33 | 39 | 40 | 41 | 42 | 43 | 49 | 50 | 51 | 52 | 53 | 54 | 64 | 66 | 72 | 73 | 74 | 75 | 76 | 77 | 83 | 85 | 91 | 92 | 93 | 94 | 96 | 97 | 100 | 101 | 102 | -------------------------------------------------------------------------------- /YXCustomIndexView.xcodeproj/xcuserdata/GeekWorld.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | TBIndexView.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | SuppressBuildableAutocreation 14 | 15 | F17058971F0B88B000D0C6BB 16 | 17 | primary 18 | 19 | 20 | F17058B01F0B88B000D0C6BB 21 | 22 | primary 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /YXCustomIndexView/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // TBIndexView 4 | // 5 | // Created by 极客天地 on 2017/7/4. 6 | // Copyright © 2017年 极客天地. 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 | -------------------------------------------------------------------------------- /YXCustomIndexView/AppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.m 3 | // TBIndexView 4 | // 5 | // Created by 极客天地 on 2017/7/4. 6 | // Copyright © 2017年 极客天地. All rights reserved. 7 | // 8 | 9 | #import "AppDelegate.h" 10 | 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 | return YES; 21 | } 22 | 23 | 24 | - (void)applicationWillResignActive:(UIApplication *)application { 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 invalidate graphics rendering callbacks. Games should use this method to pause the game. 27 | } 28 | 29 | 30 | - (void)applicationDidEnterBackground:(UIApplication *)application { 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 | 36 | - (void)applicationWillEnterForeground:(UIApplication *)application { 37 | // Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background. 38 | } 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 | 46 | - (void)applicationWillTerminate:(UIApplication *)application { 47 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 48 | } 49 | 50 | 51 | @end 52 | -------------------------------------------------------------------------------- /YXCustomIndexView/Assets.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 | "idiom" : "ipad", 35 | "size" : "29x29", 36 | "scale" : "1x" 37 | }, 38 | { 39 | "idiom" : "ipad", 40 | "size" : "29x29", 41 | "scale" : "2x" 42 | }, 43 | { 44 | "idiom" : "ipad", 45 | "size" : "40x40", 46 | "scale" : "1x" 47 | }, 48 | { 49 | "idiom" : "ipad", 50 | "size" : "40x40", 51 | "scale" : "2x" 52 | }, 53 | { 54 | "idiom" : "ipad", 55 | "size" : "76x76", 56 | "scale" : "1x" 57 | }, 58 | { 59 | "idiom" : "ipad", 60 | "size" : "76x76", 61 | "scale" : "2x" 62 | } 63 | ], 64 | "info" : { 65 | "version" : 1, 66 | "author" : "xcode" 67 | } 68 | } -------------------------------------------------------------------------------- /YXCustomIndexView/Base.lproj/LaunchScreen.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 | 28 | -------------------------------------------------------------------------------- /YXCustomIndexView/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 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | -------------------------------------------------------------------------------- /YXCustomIndexView/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | LSRequiresIPhoneOS 22 | 23 | UILaunchStoryboardName 24 | LaunchScreen 25 | UIMainStoryboardFile 26 | Main 27 | UIRequiredDeviceCapabilities 28 | 29 | armv7 30 | 31 | UISupportedInterfaceOrientations 32 | 33 | UIInterfaceOrientationPortrait 34 | UIInterfaceOrientationLandscapeLeft 35 | UIInterfaceOrientationLandscapeRight 36 | 37 | UISupportedInterfaceOrientations~ipad 38 | 39 | UIInterfaceOrientationPortrait 40 | UIInterfaceOrientationPortraitUpsideDown 41 | UIInterfaceOrientationLandscapeLeft 42 | UIInterfaceOrientationLandscapeRight 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /YXCustomIndexView/NSString+RN.h: -------------------------------------------------------------------------------- 1 | // 2 | // NSString+RN.h 3 | // bzbyTeacher 4 | // 5 | // Created by BZBY on 15/4/8. 6 | // Copyright (c) 2015年 bzby. All rights reserved. 7 | // 8 | #import 9 | 10 | typedef NS_ENUM(NSInteger, FileSuffixType) { 11 | FileSuffixTypeNuknow = -1, 12 | FileSuffixTypeVideo = 0, 13 | FileSuffixTypeAudio = 1, 14 | FileSuffixTypePicture = 2, 15 | FileSuffixTypeDocument =3 16 | 17 | }; 18 | 19 | 20 | @interface NSString (RN) 21 | +(NSString*)randomName; 22 | +(NSString*)randomPhoneNumber; 23 | +(NSString*)randomDigitalLetter; 24 | +(NSString*)randomStr; 25 | +(NSString*)randomStrWithMaxLength:(NSInteger)maxLength; 26 | +(NSString*)randomImageUrl; 27 | -(FileSuffixType)getFileType; 28 | 29 | @end 30 | -------------------------------------------------------------------------------- /YXCustomIndexView/NSString+RN.m: -------------------------------------------------------------------------------- 1 | // 2 | // NSString+RN.m 3 | // bzbyTeacher 4 | // 5 | // Created by BZBY on 15/4/8. 6 | // Copyright (c) 2015年 bzby. All rights reserved. 7 | // 8 | 9 | #import "NSString+RN.h" 10 | #define NAMES @"含蕊、亦玉、靖荷、碧萱、寒云、向南、书雁、怀薇、思菱、忆文、翠巧、怀山、若山、向秋、凡白、绮烟、从蕾、天曼、又亦、依琴、曼彤、沛槐、又槐、元绿、安珊、夏之、易槐、宛亦、白翠、丹云、问寒、易文、傲易、青旋、思真、妙之、半双、若翠、初兰、怀曼、惜萍、初之、宛丝、寄南、小萍、幻儿、千风、天蓉、雅青、寄文、代天、春海、惜珊、向薇、冬灵、惜芹、凌青、谷芹、香巧、雁桃、映雁、书兰、盼香、向山、寄风、访烟、绮晴、傲柔、寄容、以珊、紫雪、芷容、书琴、寻桃、涵阳、怀寒、易云、采蓝、代秋、惜梦、尔烟、谷槐、怀莲、涵菱、水蓝、访冬、半兰、又柔、冬卉、安双、冰岚、香薇、语芹、静珊、幻露、访天、静柏、凌丝、小翠、雁卉、访文、凌文、芷云、思柔、巧凡、慕山、依云、千柳、从凝、安梦、香旋、凡巧、映天、安柏、平萱、以筠、忆曼、新竹、绮露、觅儿、碧蓉、白竹、飞兰、曼雁、雁露、凝冬、含灵、初阳、海秋、香天、夏容。傲冬、谷翠、冰双、绿兰、盼易、思松、梦山、友灵、绿竹、灵安、凌柏、秋柔、又蓝、尔竹、香天、天蓝、青枫、问芙、语海、灵珊、凝丹、小蕾、迎夏、水之、飞珍、冰夏、亦竹、飞莲、海白、元蝶、春蕾、芷天、怀绿、尔容、元芹、若云、寒烟、听筠、采梦、凝莲、元彤、觅山、痴瑶、代桃、冷之、盼秋、秋寒、慕蕊、巧夏、海亦、初晴、巧蕊、听安、芷雪、以松、梦槐、寒梅、香岚、寄柔、映冬、孤容、晓蕾、安萱、听枫、夜绿、雪莲、从丹、碧蓉、绮琴、雨文、幼荷、青柏、痴凝、初蓝、忆安、盼晴、寻冬、雪珊、梦寒、迎南、巧香、采南、如彤、春竹、采枫、若雁、翠阳、沛容、幻翠、山兰、芷波、雪瑶、代巧、寄云、慕卉、冷松、涵梅、书白、乐天、雁卉、宛秋、傲旋、新之、凡儿、夏真、静枫、痴柏、恨蕊、乐双、白玉、问玉、寄松、丹蝶、元瑶、冰蝶、访曼、代灵、芷烟、白易、尔阳、怜烟、平卉、丹寒、访梦、绿凝、冰菱、语蕊、痴梅、思烟、忆枫、映菱、访儿、凌兰、曼岚、若枫、傲薇、凡灵、乐蕊、秋灵、谷槐、觅云 以寒、寒香、小凡、代亦、梦露、映波、友蕊、寄凡、怜蕾、雁枫、水绿、曼荷、笑珊、寒珊、谷南、慕儿、夏岚、友儿、小萱、紫青、妙菱、冬寒、曼柔、语蝶、青筠、夜安、觅海、问安、晓槐、雅山、访云、翠容、寒凡、晓绿、以菱、冬云、含玉、访枫、含卉、夜白、冷安、灵竹、醉薇、元珊、幻波、盼夏、元瑶、迎曼、水云、访琴、谷波、乐之、笑白、之山、妙海、紫霜、平夏、凌旋、孤丝、怜寒、向萍、凡松、青丝、翠安、如天、凌雪、绮菱、代云、南莲、寻南、春文、香薇、冬灵、凌珍、采绿、天春、沛文、紫槐、幻柏、采文、春梅、雪旋、盼海、映梦、安雁、映容、凝阳、访风、天亦、平绿、盼香、觅风、小霜、雪萍、半雪、山柳、谷雪、靖易、白薇、梦菡、飞绿、如波、又晴、友易、香菱、冬亦、问雁、妙春、海冬、半安、平春、幼柏、秋灵、凝芙、念烟、白山、从灵、尔芙、迎蓉、念寒、翠绿、翠芙、靖儿、妙柏、千凝、小珍、天巧。妙旋、雪枫、夏菡、元绿、痴灵、绮琴、雨双、听枫、觅荷、凡之、晓凡、雅彤、香薇、孤风、从安、绮彤、之玉、雨珍、幻丝、代梅、香波、青亦、元菱、海瑶、飞槐、听露、梦岚、幻竹、新冬、盼翠、谷云、忆霜、水瑶、慕晴、秋双、雨真、觅珍、丹雪、从阳、元枫、痴香、思天、如松、妙晴、谷秋、妙松、晓夏、香柏、巧绿、宛筠、碧琴、盼兰、小夏、安容、青曼、千儿、香春、寻双、涵瑶、冷梅、秋柔、思菱、醉波、醉柳、以寒、迎夏、向雪、香莲、以丹、依凝、如柏、雁菱、凝竹、宛白、初柔、南蕾、书萱、梦槐、香芹、南琴、绿海、沛儿、晓瑶、听春、凝蝶、紫雪、念双、念真、曼寒、凡霜、飞雪、雪兰、雅霜、从蓉、冷雪、靖巧、翠丝、觅翠、凡白、乐蓉、迎波、丹烟、梦旋、书双、念桃、夜天、海桃、青香、恨风、安筠、觅柔、初南、秋蝶、千易、安露、诗蕊、山雁、友菱、香露、晓兰、白卉、语山、冷珍、秋翠、夏柳、如之、忆南、书易、翠桃、寄瑶、如曼、问柳、香梅、幻桃、又菡、春绿、醉蝶、亦绿、诗珊、听芹、新之、易巧、念云、晓灵、静枫、夏蓉、如南、幼丝、秋白、冰安、秋白、南风、醉山、初彤、凝海、紫文、凌晴、香卉、雅琴、傲安、傲之、初蝶、寻桃、代芹、诗霜、春柏、绿夏、碧灵、诗柳、夏柳、采白、慕梅、乐安、冬菱、紫安、宛凝、雨雪、易真、安荷、静竹、代柔、丹秋、绮梅、依白、凝荷 冰巧、之槐、香柳、问春、夏寒、半香、诗筠、新梅、白曼、安波、从阳、含桃、曼卉、笑萍、碧巧、晓露、寻菡、沛白、平灵、水彤、安彤、涵易、乐巧、依风、紫南、亦丝、易蓉、紫萍、惜萱、诗蕾、寻绿、诗双、寻云、孤丹、谷蓝、惜香、谷枫、山灵、幻丝、友梅、从云、雁丝、盼旋、幼旋、尔蓝、沛山、代丝、痴梅、觅松、冰香、依玉、冰之、妙梦、以冬、碧春、曼青、冷菱、雪曼、安白、香桃、安春、千亦、凌蝶、又夏、南烟。靖易、沛凝、翠梅、书文、雪卉、乐儿、傲丝、安青、初蝶、寄灵、惜寒、雨竹、冬莲、绮南、翠柏、平凡、亦玉、孤兰、秋珊、新筠、半芹、夏瑶、念文、晓丝、涵蕾、雁凡、谷兰、灵凡、凝云、曼云、丹彤、南霜、夜梦、从筠、雁芙、语蝶、依波、晓旋、念之、盼芙、曼安、采珊、盼夏、初柳、迎天、曼安、南珍、妙芙、语柳、含莲、晓筠、夏山、尔容、采春、念梦、傲南、问薇、雨灵、凝安、冰海、初珍、宛菡、冬卉、盼晴、冷荷、寄翠、幻梅、如凡、语梦、易梦、千柔、向露、梦玉、傲霜、依霜、灵松、诗桃、书蝶、恨真、冰蝶、山槐、以晴、友易、梦桃、香菱、孤云、水蓉、雅容、飞烟、雁荷、代芙、醉易、夏烟、山梅、若南、恨桃、依秋、依波、香巧、紫萱、涵易、忆之、幻巧、水风、安寒、白亦、惜玉、碧春、怜雪、听南、念蕾、梦竹、千凡、寄琴、采波、元冬、思菱、平卉、笑柳、雪卉、南蓉、谷梦、巧兰、绿蝶、飞荷、平安、孤晴、芷荷、曼冬、寻巧、寄波、尔槐、以旋、绿蕊、初夏、依丝、怜南、千山、雨安、水风、寄柔、念巧、幼枫、凡桃、新儿、春翠、夏波、雨琴、静槐、元槐、映阳、飞薇、小凝、映寒、傲菡、谷蕊、笑槐、飞兰、笑卉、迎荷、元冬、书竹、半烟、绮波、小之、觅露、夜雪、春柔、寒梦、尔风、白梅、雨旋、芷珊、山彤、尔柳、沛柔、灵萱、沛凝、白容、乐蓉、映安、依云、映冬、凡雁、梦秋、醉柳、梦凡、秋巧、若云、元容、怀蕾、灵寒、天薇、白风、访波、亦凝、易绿、夜南、曼凡、亦巧、青易。冰真、白萱、友安、诗翠、雪珍、海之、小蕊、又琴、香彤、语梦、惜蕊、迎彤、沛白、雁山、易蓉、雪晴、诗珊、春冬、又绿、冰绿、半梅、笑容、沛凝、念瑶、天真、含巧、如冬、向真、从蓉、春柔、亦云、向雁、尔蝶、冬易、丹亦、夏山、醉香、盼夏、孤菱、安莲、问凝、冬萱、晓山、雁蓉、梦蕊、山菡、南莲、飞双、凝丝、思萱、怀梦、雨梅、冷霜、向松、迎丝、迎梅、听双、山蝶、夜梅、醉冬、巧云、雨筠、平文、青文、半蕾 碧萱、寒云、向南、书雁、怀薇、思菱、忆文、翠巧、怀山、若山、向秋、凡白、绮烟、从蕾、天曼、又亦、依琴、曼彤、沛槐、又槐、元绿、安珊、夏之、易槐、宛亦、白翠、丹云、问寒、易文、傲易、青旋、思真、妙之、半双、若翠、初兰、怀曼、惜萍、初之、宛丝、寄南、小萍、幻儿、千风、天蓉、雅青、寄文、代天、春海、惜珊、向薇、冬灵、惜芹、凌青、谷芹、香巧、雁桃、映雁、书兰、盼香、向山、寄风、访烟、绮晴、傲柔、寄容、以珊、紫雪、芷容、书琴、寻桃、涵阳、怀寒、易云、采蓝、代秋、惜梦、尔烟、谷槐、怀莲、涵菱、水蓝、访冬、半兰、又柔、冬卉、安双、冰岚、香薇、语芹、静珊、幻露、访天、静柏、凌丝、小翠、雁卉、访文、凌文、芷云、思柔、巧凡、慕山、依云、千柳、从凝、安梦、香旋、凡巧、映天、安柏、平萱、以筠、忆曼、新竹、绮露、觅儿、碧蓉、白竹、飞兰、曼雁、雁露、凝冬、含灵、初阳、海秋、香天、夏容。傲冬、谷翠、冰双、绿兰、盼易、思松、梦山、友灵、绿竹、灵安、凌柏、秋柔、又蓝、尔竹、香天、天蓝、青枫、问芙、语海、灵珊、凝丹、小蕾、迎夏、水之、飞珍、冰夏、亦竹、飞莲、海白、元蝶、春蕾、芷天、怀绿、尔容、元芹、若云、寒烟、听筠、采梦、凝莲、元彤、觅山、痴瑶、代桃、冷之、盼秋、秋寒、慕蕊、巧夏、海亦、初晴、巧蕊、听安、芷雪、以松、梦槐、寒梅、香岚、寄柔、映冬、孤容、晓蕾、安萱、听枫、夜绿、雪莲、从丹、碧蓉、绮琴、雨文、幼荷、青柏、痴凝、初蓝、忆安、盼晴、寻冬、雪珊、梦寒、迎南、巧香、采南、如彤、春竹、采枫、若雁、翠阳、沛容、幻翠、山兰、芷波、雪瑶、代巧、寄云、慕卉、冷松、涵梅、书白、乐天、雁卉、宛秋、傲旋、新之、凡儿、夏真、静枫、痴柏、恨蕊、乐双、白玉、问玉、寄松、丹蝶、元瑶、冰蝶、访曼、代灵、芷烟、白易、尔阳、怜烟、平卉、丹寒、访梦、绿凝、冰菱、语蕊、痴梅、思烟、忆枫、映菱、访儿、凌兰、曼岚、若枫、傲薇、凡灵、乐蕊、秋灵、谷槐、觅云 幼珊、忆彤、凌青、之桃、芷荷、听荷、代玉、念珍、梦菲、夜春、千秋、白秋、谷菱、飞松、初瑶、惜灵、恨瑶、梦易、新瑶、曼梅、碧曼、友瑶、雨兰、夜柳、香蝶、盼巧、芷珍、香卉、含芙、夜云、依萱、凝雁、以莲、易容、元柳、安南、幼晴、尔琴、飞阳、白凡、沛萍、雪瑶、向卉、采文、乐珍、寒荷、觅双、白桃、安卉、迎曼、盼雁、乐松、涵山、恨寒、问枫、以柳、含海、秋春、翠曼、忆梅、涵柳、梦香、海蓝、晓曼、代珊、春冬、恨荷、忆丹、静芙、绮兰、梦安、紫丝、千雁、凝珍、香萱、梦容、冷雁、飞柏、天真、翠琴、寄真、秋荷、代珊、初雪、雅柏、怜容、如风、南露、紫易、冰凡、海雪、语蓉、碧玉、翠岚、语风、盼丹、痴旋、凝梦、从雪、白枫、傲云、白梅、念露、慕凝、雅柔、盼柳、半青、从霜、怀柔、怜晴、夜蓉、代双、以南、若菱、芷文、寄春、南晴、恨之、梦寒、初翠、灵波、巧春、问夏、凌春、惜海、亦旋、沛芹、幼萱、白凝、初露、迎海、绮玉、凌香、寻芹、秋柳、尔白、映真、含雁、寒松、友珊、寻雪、忆柏、秋柏、巧风、恨蝶、青烟、问蕊、灵阳、春枫、又儿、雪巧、丹萱、凡双、孤萍、紫菱、寻凝、傲柏、傲儿、友容、灵枫、尔丝、曼凝、若蕊、问丝、思枫、水卉、问梅、念寒、诗双、翠霜、夜香、寒蕾、凡阳、冷玉、平彤、语薇、幻珊、紫夏、凌波、芷蝶、丹南、之双、凡波、思雁、白莲、从菡、如容、采柳、沛岚、惜儿、夜玉、水儿、半凡、语海、听莲、幻枫、念柏、冰珍、思山、凝蕊、天玉、问香、思萱、向梦、笑南、夏旋、之槐、元灵、以彤、采萱、巧曼、绿兰、平蓝、问萍、绿蓉、靖柏。迎蕾、碧曼、思卉、白柏、妙菡、怜阳、雨柏、雁菡、梦之、又莲、乐荷、寒天、凝琴、书南、映天、白梦、初瑶、恨竹、平露、含巧、慕蕊、半莲、醉卉、天菱、青雪、雅旋、巧荷、飞丹、恨云、若灵、尔云、幻天、诗兰、青梦、海菡、灵槐、忆秋、寒凝、凝芙、绮山、静白、尔蓉、尔冬、映萱、白筠、冰双、访彤、绿柏、夏云、笑翠、晓灵、含双、盼波、以云、怜翠、雁风、之卉、平松、问儿、绿柳、如蓉、曼容、天晴、丹琴、惜天、寻琴、痴春、依瑶、涵易、忆灵、从波、依柔、问兰、山晴、怜珊、之云、飞双、傲白、沛春、雨南、梦之、笑阳、代容、友琴、雁梅、友桃、从露、语柔、傲玉、觅夏、晓蓝、新晴、雨莲、凝旋、绿旋、幻香、觅双、冷亦、忆雪、友卉、幻翠、靖柔、寻菱、丹翠、安阳、雅寒、惜筠、尔安、雁易、飞瑶、夏兰、沛蓝、静丹、山芙、笑晴、新烟、笑旋、雁兰、凌翠、秋莲、书桃、傲松、语儿、映菡、初曼、听云、孤松、初夏、雅香、语雪、初珍、白安、冰薇、诗槐、冷玉 梦琪、忆柳、之桃、慕青、问兰、尔岚、元香、初夏、沛菡、傲珊、曼文、乐菱、痴珊、恨玉、惜文、香寒、新柔、语蓉、海安、夜蓉、涵柏、水桃、醉蓝、春儿、语琴、从彤、傲晴、语兰、又菱、碧彤、元霜、怜梦、紫寒、妙彤、曼易、南莲、紫翠、雨寒、易烟、如萱、若南、寻真、晓亦、向珊、慕灵、以蕊、寻雁、映易、雪柳、孤岚、笑霜、海云、凝天、沛珊、寒云、冰旋、宛儿、绿真、盼儿、晓霜、碧凡、夏菡、曼香、若烟、半梦、雅绿、冰蓝、灵槐、平安、书翠、翠风、香巧、代云、梦曼、幼翠、友巧、听寒、梦柏、醉易、访旋、亦玉、凌萱、访卉、怀亦、笑蓝、春翠、靖柏、夜蕾、冰夏、梦松、书雪、乐枫、念薇、靖雁、寻春、恨山、从寒、忆香、觅波、静曼、凡旋、以亦、念露、芷蕾、千兰、新波、代真、新蕾、雁玉、冷卉、紫山、千琴、恨天、傲芙、盼山、怀蝶、冰兰、山柏、翠萱、恨松、问旋、从南、白易、问筠、如霜、半芹、丹珍、冰彤、亦寒、寒雁、怜云、寻文、乐丹、翠柔、谷山、之瑶、冰露、尔珍、谷雪、乐萱、涵菡、海莲、傲蕾、青槐、冬儿、易梦、惜雪、宛海、之柔、夏青、亦瑶、妙菡、春竹、痴梦、紫蓝、晓巧、幻柏、元风、冰枫、访蕊、南春、芷蕊、凡蕾、凡柔、安蕾、天荷、含玉、书兰、雅琴、书瑶、春雁、从安、夏槐、念芹、怀萍、代曼、幻珊、谷丝、秋翠、白晴、海露、代荷、含玉、书蕾、听白、访琴、灵雁、秋春、雪青、乐瑶、含烟、涵双、平蝶、雅蕊、傲之、灵薇、绿春、含蕾、从梦、从蓉、初丹。听兰、听蓉、语芙、夏彤、凌瑶、忆翠、幻灵、怜菡、紫南、依珊、妙竹、访烟、怜蕾、映寒、友绿、冰萍、惜霜、凌香、芷蕾、雁卉、迎梦、元柏、代萱、紫真、千青、凌寒、紫安、寒安、怀蕊、秋荷、涵雁、以山、凡梅、盼曼、翠彤、谷冬、新巧、冷安、千萍、冰烟、雅阳、友绿、南松、诗云、飞风、寄灵、书芹、幼蓉、以蓝、笑寒、忆寒、秋烟、芷巧、水香、映之、醉波、幻莲、夜山、芷卉、向彤、小玉、幼南、凡梦、尔曼、念波、迎松、青寒、笑天、涵蕾、碧菡、映秋、盼烟、忆山" 11 | 12 | #define XS @"赵钱孙李周吴郑王冯陈诸卫蒋沈韩杨朱秦尤许何吕施张孔曹严华金魏陶姜戚谢邹喻柏水窦章云苏潘葛奚范彭郎鲁韦昌马苗凤花方俞任袁柳酆鲍史唐费廉岑薛雷贺倪汤滕殷罗毕郝邬安常乐于时傅皮卡齐康伍余元卜顾孟平黄和穆萧尹姚邵堪汪祁毛禹狄米贝明臧计伏成戴谈宋茅庞熊纪舒屈项祝董粱杜阮蓝闵席季麻强贾路娄危江童颜郭梅盛林刁钟徐邱骆高夏蔡田樊胡凌霍虞万支柯咎管卢莫经房裘缪干解应丁宣贲邓郁单杭洪包诸左石崔吉钮龚程嵇邢滑裴陆荣翁荀羊於惠甄魏家封芮羿储靳汲邴糜松井段富巫乌焦巴弓牧隗谷车侯宓蓬全郗班仰秋仲伊宫" 13 | 14 | 15 | #define OSTR @"在红楼梦中,史湘云颇具男孩子的性格特征,是个个性比较随,天真烂漫、活力四射的少女。她无一处不显示出她对生活的热爱。她心直口快,无所顾忌,不拘小节,说话从不转弯抹角,喜欢直来直去,任意高谈阔论,想说什么就说什么,心里想什么就说什么,快人快语,从不藏着掩着。她无拘无束,心胸开阔,生性豪放,具有鲜活靓丽的生命力和豪爽不羁的潇洒风度,是个无忧无虑,是个活泼快乐,充满青春气息,很阳光,很乐观的女孩。她不象林黛玉那样的敏感多疑,也不象薛宝钗的工于心计。她没有林黛玉的忧郁,也没有薛宝钗的深沉。她不清高,也不媚俗,她自尊但不自卑,她不象林黛玉的目无下尘,也不似宝钗的刻意去迎合。每次由于她的到来,大观园便增添了几多的欢声笑语和无穷的情趣。她自幼父母双亡,命运多舛,但是由于从小没有得过父母的疼爱,所以不幸的身世并没有在她心灵深处留下的多少生活的阴影。史湘云的诗词比较散淡,也比较随意,介于林黛玉与薛宝钗之间。史湘云的诗词豪爽不拘,完全是以一个男儿的口吻来写的,调子轻快而活泼,具有一种男子的潇洒风流,俏丽妩媚中尽显男儿风采。她锦心绣口,才思敏锐,诗意怡然 ,诗情潇洒飘逸,随意性很强。她的性格特征,她的思想倾向在她的咏海棠和咏菊花中都一一表现了出来" 16 | 17 | 18 | 19 | 20 | static const NSString * videoSuffixs = @"avi,rmvb,rm,asf,divx,mpg,mpeg,mpe,wmv,mp4,mkv,vob,3gp"; 21 | 22 | static const NSString * audioSuffixs = @"mp3,wma,ogg,aac,wav,pcm,tta,flac,au,ape,tak,wv,m4a"; 23 | 24 | static const NSString * pictureSuffixs = @"bmp,jpg,png,tif,tiff,gif,jpeg,ico"; 25 | 26 | static const NSString * documentSuffixs = @"txt,doc,docx,xls,xlsx,ppt,pptx,pdf,zip,rar,java,js,html,bat,m,h"; 27 | 28 | @implementation NSString (RN) 29 | 30 | static NSArray * nArray; 31 | +(NSString*)randomName{ 32 | NSString * randomName = nil; 33 | if(nil == nArray){ 34 | nArray = [NAMES componentsSeparatedByString:@"、"]; 35 | } 36 | NSInteger xIndex = (NSInteger)arc4random_uniform((u_int32_t)XS.length-1)+1; 37 | NSInteger mIndex = (NSInteger)arc4random_uniform((u_int32_t)nArray.count-1); 38 | NSString * x = [XS substringWithRange:NSMakeRange(xIndex,1)]; 39 | NSString * m = nArray[mIndex]; 40 | randomName = [NSString stringWithFormat:@"%@%@",x,m]; 41 | return randomName; 42 | } 43 | +(NSString*)randomPhoneNumber{ 44 | NSString * randomPhoneNumber = @"1"; 45 | NSArray * array2 = @[@"3",@"5",@"7",@"8"]; 46 | NSArray * array = @[@"0",@"1",@"2",@"3",@"4",@"5",@"6",@"7",@"8",@"9"]; 47 | NSInteger index = arc4random_uniform((int)array2.count); 48 | randomPhoneNumber = [randomPhoneNumber stringByAppendingFormat:@"%@",array2[index]]; 49 | for(NSInteger i = 0;i<9;i++){ 50 | index = arc4random_uniform((int)array.count); 51 | randomPhoneNumber = [randomPhoneNumber stringByAppendingFormat:@"%@",array[index]]; 52 | } 53 | return randomPhoneNumber; 54 | } 55 | 56 | +(NSString*)randomDigitalLetter{ 57 | NSString * randomDigitalLetter = nil; 58 | NSString * letterStr = @"ABCDEFGHIJKLMNOPQRSTUVWXYZ"; 59 | NSString * digitalStr = @"1234567890"; 60 | NSInteger loc1 = arc4random_uniform((int)letterStr.length-2); 61 | NSInteger len1 = 2; 62 | NSRange range1 = NSMakeRange(loc1, len1); 63 | 64 | NSInteger loc2 = arc4random_uniform((int)digitalStr.length-2); 65 | NSInteger len2 = 2; 66 | NSRange range2 = NSMakeRange(loc2, len2); 67 | 68 | randomDigitalLetter = [NSString stringWithFormat:@"%@-%@",[letterStr substringWithRange:range1],[digitalStr substringWithRange:range2]]; 69 | 70 | return randomDigitalLetter; 71 | } 72 | +(NSString*)randomStr{ 73 | NSInteger location = (NSInteger)arc4random_uniform((u_int32_t)OSTR.length-1); 74 | NSInteger length = (NSInteger)arc4random_uniform((u_int32_t)(OSTR.length-location)); 75 | NSRange range = NSMakeRange(location, length>200?200:length); 76 | return [OSTR substringWithRange:range]; 77 | } 78 | +(NSString*)randomStrWithMaxLength:(NSInteger)maxLength{ 79 | NSInteger location = (NSInteger)arc4random_uniform((u_int32_t)OSTR.length-1); 80 | NSInteger length = (NSInteger)arc4random_uniform((u_int32_t)(OSTR.length-location)); 81 | NSRange range = NSMakeRange(location, length>maxLength?maxLength:length); 82 | return [OSTR substringWithRange:range]; 83 | } 84 | +(NSString *)randomImageUrl{ 85 | NSArray * array = @[ 86 | @"http://h.hiphotos.baidu.com/image/w%3D400/sign=e9d4bc7593529822053338c3e7cb7b3b/b3119313b07eca80cacfb955922397dda04483be.jpg", 87 | @"http://d.hiphotos.baidu.com/image/w%3D400/sign=66fe39e3d739b6004dce0eb7d9503526/37d12f2eb9389b503cf2da528735e5dde7116ea4.jpg", 88 | @"http://d.hiphotos.baidu.com/image/w%3D400/sign=f0c605ea3a12b31bc76ccc29b6193674/a1ec08fa513d2697daa591f056fbb2fb4316d82d.jpg", 89 | @"http://b.hiphotos.baidu.com/image/w%3D400/sign=3f39af08b4003af34dbadd60052bc619/2e2eb9389b504fc2dc88ff04e7dde71191ef6ddf.jpg", 90 | @"http://h.hiphotos.baidu.com/image/w%3D400/sign=676cba4c249759ee4a5061cb82fa434e/37d3d539b6003af355110221372ac65c1138b6cc.jpg", 91 | @"http://e.hiphotos.baidu.com/image/w%3D400/sign=3603c4d40ff431adbcd242397b37ac0f/e1fe9925bc315c60b01c4aa98eb1cb13485477ee.jpg", 92 | @"http://c.hiphotos.baidu.com/image/w%3D400/sign=60752862b37eca80120538e7a1229712/cf1b9d16fdfaaf5121ba0ffe8f5494eef01f7a12.jpg", 93 | @"http://c.hiphotos.baidu.com/image/w%3D400/sign=29763de45bafa40f3cc6cfdd9b65038c/9f2f070828381f30b3a2077fa8014c086f06f0a9.jpg", 94 | @"http://f.hiphotos.baidu.com/image/w%3D400/sign=f04304ccf0deb48ffb69a0dec01e3aef/94cad1c8a786c9177287cc94ca3d70cf3ac75792.jpg", 95 | @"http://c.hiphotos.baidu.com/image/w%3D400/sign=b338613a6c061d957d4636384bf40a5d/6a63f6246b600c339d7dc6ca184c510fd9f9a1af.jpg", 96 | @"http://c.hiphotos.baidu.com/image/w%3D400/sign=768d60c61f950a7b75354fc43ad0625c/f7246b600c338744d17d148c530fd9f9d62aa081.jpg", 97 | @"http://www.33.la/uploads/20140403sj/6275.jpg", 98 | @"http://www.33.la/uploads/20140403sj/7198.jpg", 99 | @"http://d.3987.com/xllq_140102/009.jpg", 100 | @"http://d.3987.com/wzbz_140702/001.jpg" 101 | ]; 102 | NSInteger index = (NSInteger)arc4random_uniform((u_int32_t)(array.count-1))+1; 103 | return array[index]; 104 | } 105 | -(FileSuffixType)getFileType{ 106 | FileSuffixType type = FileSuffixTypeNuknow; 107 | NSArray * videoSuffixArray = [videoSuffixs componentsSeparatedByString:@","]; 108 | NSArray * audioSuffixArray = [audioSuffixs componentsSeparatedByString:@","]; 109 | NSArray * pictureSuffixArray = [pictureSuffixs componentsSeparatedByString:@","]; 110 | NSArray * documentSuffixArray = [documentSuffixs componentsSeparatedByString:@","]; 111 | if([videoSuffixArray containsObject:[self lowercaseString]]){ 112 | type = FileSuffixTypeVideo; 113 | }else if([audioSuffixArray containsObject:[self lowercaseString]]){ 114 | type = FileSuffixTypeAudio; 115 | }else if([pictureSuffixArray containsObject:[self lowercaseString]]){ 116 | type = FileSuffixTypePicture; 117 | }else if([documentSuffixArray containsObject:[self lowercaseString]]){ 118 | type = FileSuffixTypeDocument; 119 | } 120 | return type; 121 | } 122 | 123 | @end 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | -------------------------------------------------------------------------------- /YXCustomIndexView/ViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.h 3 | // TBIndexView 4 | // 5 | // Created by 极客天地 on 2017/7/4. 6 | // Copyright © 2017年 极客天地. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface ViewController : UIViewController 12 | 13 | 14 | @end 15 | 16 | -------------------------------------------------------------------------------- /YXCustomIndexView/ViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.m 3 | // TBIndexView 4 | // 5 | // Created by 极客天地 on 2017/7/4. 6 | // Copyright © 2017年 极客天地. All rights reserved. 7 | // 8 | 9 | #import "ViewController.h" 10 | #import "NSString+RN.h" 11 | 12 | 13 | #import "YXTableViewIndexView.h" 14 | 15 | @interface ViewController () 16 | @property (weak, nonatomic) IBOutlet UITableView *tableView; 17 | 18 | 19 | @property (strong,nonatomic) NSMutableArray * dataArray; 20 | 21 | @property (strong,nonatomic) NSMutableArray * groupDataArray; 22 | @property (strong,nonatomic) NSMutableArray * groupTitleArray; 23 | 24 | @property (strong,nonatomic) YXTableViewIndexView * tableViewIndexView; 25 | 26 | 27 | @end 28 | 29 | @implementation ViewController 30 | -(NSMutableArray *)dataArray{ 31 | if(nil == _dataArray){ 32 | _dataArray = [[NSMutableArray alloc] init]; 33 | NSInteger count = arc4random_uniform(90)+10; 34 | for(int i = 0;i *)sectionIndexTitlesForTableView:(UITableView *)tableView{ 165 | //用自定义的索引视图 166 | [self.tableViewIndexView setIndexTitlesArray:self.groupTitleArray]; 167 | return nil; 168 | } 169 | 170 | 171 | -(void)scrollViewDidScroll:(UIScrollView *)scrollView{ 172 | 173 | } 174 | @end 175 | -------------------------------------------------------------------------------- /YXCustomIndexView/YXTableViewIndexView/.svn/entries: -------------------------------------------------------------------------------- 1 | 10 2 | 3 | dir 4 | 2499 5 | svn://zhangyongxu@182.92.3.116/repo/trunk/iOS/BoBo/BoBo/Views/tableViewIndexView 6 | svn://zhangyongxu@182.92.3.116/repo 7 | 8 | 9 | 10 | 2015-07-01T03:42:18.683489Z 11 | 1005 12 | zhangyongxu 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | a5a8fac7-4bab-45a5-b04b-d0a8fe340961 28 | 29 | TableViewIndexView.m 30 | file 31 | 32 | 33 | 34 | 35 | 2015-07-01T03:55:24.000000Z 36 | dc0e5b7f5a9806606d44d25285c50708 37 | 2015-07-01T03:42:18.683489Z 38 | 1005 39 | zhangyongxu 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 10009 62 | 63 | TableViewIndexView.xib 64 | file 65 | 66 | 67 | 68 | 69 | 2015-06-24T01:05:56.000000Z 70 | dcc40cbb5fd367841901d91fa0cd2208 71 | 2015-06-19T02:42:49.488789Z 72 | 801 73 | zhaoxiaojun 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 1371 96 | 97 | TableViewIndexView.h 98 | file 99 | 100 | 101 | 102 | 103 | 2015-06-24T01:05:56.000000Z 104 | 7531e60fb3491173c7323bcadc8d38a1 105 | 2015-06-19T02:42:49.488789Z 106 | 801 107 | zhaoxiaojun 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 582 130 | 131 | -------------------------------------------------------------------------------- /YXCustomIndexView/YXTableViewIndexView/.svn/text-base/TableViewIndexView.h.svn-base: -------------------------------------------------------------------------------- 1 | // 2 | // SMDTableViewIndexView.h 3 | // Echo 4 | // 5 | // Created by robu on 15/2/2. 6 | // Copyright (c) 2015年 Static Ga. All rights reserved. 7 | // 8 | 9 | #import "RootCustomView.h" 10 | @protocol TableViewIndexViewDelegate; 11 | 12 | @interface TableViewIndexView : RootCustomView 13 | @property (strong,nonatomic) UITableView * tableView; 14 | @property (assign,nonatomic) id tabelViewIndexViewDelegate; 15 | 16 | -(void)setIndexTitlesArray:(NSArray*)titlesArray; 17 | 18 | @end 19 | 20 | @protocol TableViewIndexViewDelegate 21 | 22 | - (void)tableViewSectionIndexTitle:(NSString *)title atIndex:(NSInteger)index; 23 | 24 | @end -------------------------------------------------------------------------------- /YXCustomIndexView/YXTableViewIndexView/.svn/text-base/TableViewIndexView.m.svn-base: -------------------------------------------------------------------------------- 1 | // 2 | // SMDTableViewIndexView.m 3 | // Echo 4 | // 5 | // Created by robu on 15/2/2. 6 | // Copyright (c) 2015年 Static Ga. All rights reserved. 7 | // 8 | 9 | #import "TableViewIndexView.h" 10 | 11 | #import "UIView+ITTAdditions.h" 12 | #import "UIColor+HEX.h" 13 | 14 | #define titleLabel_w 12 15 | #define titleLabel_h 12 16 | #define titleLabel_font 9 17 | #define titleLabel_right_margin 12/2.0 18 | #define titleLabel_top_margin 24/2.0 19 | #define titleLabel_vertical_margin_default 4/2.0 20 | 21 | 22 | 23 | @interface TableViewIndexView() 24 | @property (assign,nonatomic) CGFloat titleLabelW; 25 | @property (assign,nonatomic) CGFloat titleLabelH; 26 | @property (assign,nonatomic) CGFloat titleLabelFont; 27 | @property (assign,nonatomic) CGFloat titleLabelTopMargin; 28 | @property (assign,nonatomic) CGFloat titleLabelRightMargin; 29 | @property (assign,nonatomic) CGFloat titleLabelVerticalMargin; 30 | 31 | @property (strong,nonatomic)NSMutableArray * titlesArray; 32 | @property (strong,nonatomic)NSMutableArray * titleLabelsArray; 33 | @property (strong,nonatomic)NSMutableArray * titleLabelCacheArray; 34 | 35 | @property (assign,nonatomic)BOOL isMoveOutView;//touches事件是否移动超出当前view 36 | 37 | @property (strong,nonatomic) UIImageView * titleTipImageView; 38 | @property (strong,nonatomic) UILabel * titleTipLabel; 39 | @end 40 | @implementation TableViewIndexView 41 | 42 | -(instancetype)init{ 43 | if(self = [super init]){ 44 | [self initData]; 45 | [self initUI]; 46 | } 47 | return self; 48 | } 49 | -(instancetype)initWithFrame:(CGRect)frame{ 50 | if(self == [super initWithFrame:frame]){ 51 | [self initData]; 52 | [self initUI]; 53 | } 54 | return self; 55 | } 56 | -(void)awakeFromNib{ 57 | [super awakeFromNib]; 58 | [self initData]; 59 | [self initUI]; 60 | } 61 | -(void)initData{ 62 | if(nil == self.titleLabelsArray){ 63 | self.titleLabelsArray = [[NSMutableArray alloc] init]; 64 | } 65 | if(nil == self.titleLabelCacheArray){ 66 | self.titleLabelCacheArray = [[NSMutableArray alloc] init]; 67 | } 68 | self.titleLabelW = titleLabel_w; 69 | self.titleLabelH = titleLabel_h; 70 | self.titleLabelFont = titleLabel_font; 71 | self.titleLabelTopMargin = titleLabel_top_margin; 72 | self.titleLabelRightMargin = titleLabel_right_margin; 73 | self.titleLabelVerticalMargin = titleLabel_vertical_margin_default; 74 | 75 | } 76 | -(void)initUI{ 77 | self.backgroundColor = [UIColor clearColor]; 78 | 79 | if(nil == self.titleTipImageView){ 80 | self.titleTipImageView = [[UIImageView alloc] init]; 81 | } 82 | if(nil == self.titleTipLabel){ 83 | self.titleTipLabel = [[UILabel alloc] init]; 84 | } 85 | 86 | self.titleTipImageView.frame = CGRectMake(-(10/2.0+110/2.0), 0, 110/2.0, 100/2.0); 87 | 88 | //self.titleTipImageView.image = [UIImage imageNamed:@"Contacts_Screening_"]; 89 | UIImage *image = [UIImage imageNamed:@"show_head_toast_bg"]; 90 | UIImage * strenImage = [image stretchableImageWithLeftCapWidth:image.size.width/2 topCapHeight:image.size.height/2]; 91 | self.titleTipImageView.image = strenImage; 92 | self.titleTipImageView.centerX = -SCREEN_WIDHT/2.0+self.width; 93 | self.titleTipImageView.centerY = SCREEN_HEIGHT/2.0-64; 94 | self.titleTipImageView.backgroundColor = [UIColor colorWithHex:0x01cdce]; 95 | self.titleTipImageView.layer.masksToBounds = YES; 96 | self.titleTipImageView.layer.cornerRadius = 4; 97 | 98 | self.titleTipLabel.frame = CGRectMake(0, 0, 17, 17); 99 | self.titleTipLabel.centerY = self.titleTipImageView.height/2.0; 100 | self.titleTipLabel.left = 38/2.0; 101 | 102 | self.titleTipLabel.font = [UIFont systemFontOfSize:17]; 103 | self.titleTipLabel.textAlignment = NSTextAlignmentCenter; 104 | //self.titleTipLabel.textColor = [UIColor colorWithHex:0x6e7278]; 105 | self.titleTipLabel.textColor = [UIColor whiteColor]; 106 | self.titleTipLabel.backgroundColor = [UIColor clearColor]; 107 | [self.titleTipImageView addSubview:self.titleTipLabel]; 108 | 109 | self.titleTipImageView.hidden = YES; 110 | [self addSubview:self.titleTipImageView]; 111 | } 112 | -(void)refreshUI{ 113 | if(self.titlesArray.count<=0){ 114 | return; 115 | } 116 | self.width = 20; 117 | self.height = (self.titleLabelH+titleLabel_vertical_margin_default)*self.titlesArray.count + 14/2.0; 118 | //NSLog(@"titleLabelW=%f titleLabelVerticalMargin=%f",self.titleLabelW,self.titleLabelVerticalMargin); 119 | if(nil != self.tableView){ 120 | if(self.height>=self.tableView.height-10){ 121 | self.height = self.tableView.height-10; 122 | 123 | CGFloat verticalMargin = (self.height - self.titleLabelTopMargin)/self.titlesArray.count - self.titleLabelH; 124 | if(verticalMargin14/2.0){ 132 | self.titleLabelVerticalMargin = 14/2.0; 133 | }else{ 134 | self.titleLabelVerticalMargin = titleLabel_vertical_margin_default; 135 | } 136 | self.height = (self.titleLabelH+self.titleLabelVerticalMargin)*self.titlesArray.count + 14/2.0; 137 | } 138 | self.centerY = self.tableView.centerY; 139 | } 140 | 141 | 142 | 143 | CGFloat x = 0; 144 | CGFloat y = 0; 145 | CGFloat w = self.titleLabelW; 146 | CGFloat h = self.titleLabelH; 147 | for(int i = 0;i 0){ 174 | label = [self.titleLabelCacheArray lastObject]; 175 | [self.titleLabelCacheArray removeLastObject]; 176 | } 177 | return label; 178 | } 179 | -(void)setIndexTitlesArray:(NSArray*)titlesArray{ 180 | if(nil == self.titlesArray){ 181 | self.titlesArray = [[NSMutableArray alloc] init]; 182 | } 183 | [self.titlesArray removeAllObjects]; 184 | [self.titlesArray addObjectsFromArray:titlesArray]; 185 | 186 | [self.titleLabelCacheArray addObjectsFromArray:self.titleLabelsArray]; 187 | [self.titleLabelsArray removeAllObjects]; 188 | 189 | [self refreshUI]; 190 | } 191 | /* 事件处理 */ 192 | -(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{ 193 | // self.backgroundColor = [UIColor colorWithWhite:0 alpha:0.4]; 194 | //NSLog(@"touchesBegan...%@",NSStringFromClass([self class])); 195 | self.isMoveOutView = NO; 196 | UITouch *touch=[touches anyObject]; 197 | CGPoint location = [touch locationInView:self]; 198 | //NSLog(@"touchesBegan..location = %@",NSStringFromCGPoint(location)); 199 | [self indexTouchedInView:location.y]; 200 | 201 | } 202 | -(void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event{ 203 | self.backgroundColor = [UIColor clearColor]; 204 | //NSLog(@"touchesEnded...%@",NSStringFromClass([self class])); 205 | 206 | UITouch *touch=[touches anyObject]; 207 | CGPoint location = [touch locationInView:self]; 208 | //NSLog(@"touchesEnded..location = %@",NSStringFromCGPoint(location)); 209 | if(!self.isMoveOutView){//点击事件有效 210 | [self indexTouchedInView:location.y]; 211 | }else{//点击事件无效 212 | 213 | } 214 | self.titleTipImageView.hidden = YES; 215 | } 216 | -(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event{ 217 | //NSLog(@"touchesMoved...%@",NSStringFromClass([self class])); 218 | 219 | UITouch *touch=[touches anyObject]; 220 | 221 | CGPoint location = [touch locationInView:self]; 222 | //NSLog(@"touchesMoved..location = %@",NSStringFromCGPoint(location)); 223 | 224 | if (![self pointInside:[touch locationInView:self] withEvent:nil]) { 225 | //NSLog(@"touches moved outside the view"); 226 | self.isMoveOutView = YES; 227 | }else{ 228 | self.isMoveOutView = NO; 229 | UIView *hitView=[self hitTest:[[touches anyObject] locationInView:self] withEvent:nil]; 230 | if (hitView==self){ 231 | //NSLog(@"touches moved in the view"); 232 | }else 233 | { 234 | //NSLog(@"touches moved in the subview"); 235 | } 236 | [self indexTouchedInView:location.y]; 237 | } 238 | } 239 | -(void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event{ 240 | self.backgroundColor = [UIColor clearColor]; 241 | //NSLog(@"touchesCancelled...%@",NSStringFromClass([self class])); 242 | self.titleTipImageView.hidden = YES; 243 | 244 | } 245 | -(NSInteger)indexTouchedInView:(CGFloat)locationY{ 246 | NSInteger index = [self getCurrentLabelWithLoactionY:locationY]; 247 | if(index<0){ 248 | return index; 249 | } 250 | NSString * title = self.titlesArray[index]; 251 | self.titleTipLabel.text = title; 252 | //UILabel * label = self.titleLabelsArray[index]; 253 | //self.titleTipImageView.centerY = label.centerY; 254 | self.titleTipImageView.hidden = NO; 255 | if([self.tabelViewIndexViewDelegate respondsToSelector:@selector(tableViewSectionIndexTitle:atIndex:)]){ 256 | [self.tabelViewIndexViewDelegate tableViewSectionIndexTitle:title atIndex:index]; 257 | } 258 | return index; 259 | } 260 | -(NSInteger)getCurrentLabelWithLoactionY:(CGFloat)locationY{ 261 | NSInteger index = (locationY - self.titleLabelTopMargin)/(self.titleLabelW+self.titleLabelVerticalMargin); 262 | //NSLog(@"getCurrentLabelWithLoactionY..index = %ld",index); 263 | if(index>=self.titlesArray.count){ 264 | index = self.titlesArray.count - 1; 265 | } 266 | if(index<0){ 267 | index = 0; 268 | } 269 | if(0 == self.titlesArray.count){ 270 | return -1; 271 | } 272 | return index; 273 | } 274 | 275 | @end 276 | -------------------------------------------------------------------------------- /YXCustomIndexView/YXTableViewIndexView/.svn/text-base/TableViewIndexView.xib.svn-base: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /YXCustomIndexView/YXTableViewIndexView/YXTableViewIndexView.h: -------------------------------------------------------------------------------- 1 | // 2 | // 3 | // Created by robu on 17/2/2. 4 | // Copyright (c) 2017年 Static Ga. All rights reserved. 5 | // 6 | 7 | #import 8 | 9 | @interface YXTableViewIndexView : UIView 10 | @property (strong,nonatomic) UITableView * tableView; 11 | 12 | @property(assign,nonatomic) BOOL isShowTipView; 13 | @property(assign,nonatomic) UIImage* tipViewBackgroundImage; 14 | @property(assign,nonatomic) UIColor* tipViewBackgroundColor; 15 | @property(assign,nonatomic) UIColor* tipViewTitleColor; 16 | @property(assign,nonatomic) UIFont* tipViewTitleFont; 17 | + (id)loadFromXib; 18 | -(void)setIndexTitlesArray:(NSArray*)titlesArray; 19 | 20 | @end 21 | 22 | 23 | -------------------------------------------------------------------------------- /YXCustomIndexView/YXTableViewIndexView/YXTableViewIndexView.m: -------------------------------------------------------------------------------- 1 | // 2 | // 3 | // Created by robu on 17/2/2. 4 | // Copyright (c) 2017年 Static Ga. All rights reserved. 5 | // 6 | 7 | #import "YXTableViewIndexView.h" 8 | 9 | 10 | #define titleLabel_w 12 11 | #define titleLabel_h 12 12 | #define titleLabel_font 9 13 | #define titleLabel_right_margin 12/2.0 14 | #define titleLabel_top_margin 24/2.0 15 | #define titleLabel_vertical_margin_default 4/2.0 16 | 17 | 18 | 19 | @interface YXTableViewIndexView() 20 | @property (assign,nonatomic) CGFloat titleLabelW; 21 | @property (assign,nonatomic) CGFloat titleLabelH; 22 | @property (assign,nonatomic) CGFloat titleLabelFont; 23 | @property (assign,nonatomic) CGFloat titleLabelTopMargin; 24 | @property (assign,nonatomic) CGFloat titleLabelRightMargin; 25 | @property (assign,nonatomic) CGFloat titleLabelVerticalMargin; 26 | 27 | @property (strong,nonatomic)NSMutableArray * titlesArray; 28 | @property (strong,nonatomic)NSMutableArray * titleLabelsArray; 29 | @property (strong,nonatomic)NSMutableArray * titleLabelCacheArray; 30 | 31 | @property (assign,nonatomic)BOOL isMoveOutView;//touches事件是否移动超出当前view 32 | 33 | @property (strong,nonatomic) UIImageView * titleTipImageView; 34 | @property (strong,nonatomic) UILabel * titleTipLabel; 35 | @end 36 | @implementation YXTableViewIndexView 37 | 38 | 39 | + (id)loadFromXib{ 40 | NSBundle * bundle = [NSBundle mainBundle]; 41 | return [[bundle loadNibNamed:NSStringFromClass([self class]) owner:nil options:nil] lastObject]; 42 | } 43 | 44 | -(instancetype)init{ 45 | if(self = [super init]){ 46 | [self initData]; 47 | [self initUI]; 48 | } 49 | return self; 50 | } 51 | -(instancetype)initWithFrame:(CGRect)frame{ 52 | if(self == [super initWithFrame:frame]){ 53 | [self initData]; 54 | [self initUI]; 55 | } 56 | return self; 57 | } 58 | -(void)awakeFromNib{ 59 | [super awakeFromNib]; 60 | [self initData]; 61 | [self initUI]; 62 | } 63 | -(void)initData{ 64 | if(nil == self.titleLabelsArray){ 65 | self.titleLabelsArray = [[NSMutableArray alloc] init]; 66 | } 67 | if(nil == self.titleLabelCacheArray){ 68 | self.titleLabelCacheArray = [[NSMutableArray alloc] init]; 69 | } 70 | self.titleLabelW = titleLabel_w; 71 | self.titleLabelH = titleLabel_h; 72 | self.titleLabelFont = titleLabel_font; 73 | self.titleLabelTopMargin = titleLabel_top_margin; 74 | self.titleLabelRightMargin = titleLabel_right_margin; 75 | self.titleLabelVerticalMargin = titleLabel_vertical_margin_default; 76 | 77 | } 78 | -(void)initUI{ 79 | self.backgroundColor = [UIColor clearColor]; 80 | self.isShowTipView = NO; 81 | 82 | if(nil == self.titleTipImageView){ 83 | self.titleTipImageView = [[UIImageView alloc] init]; 84 | } 85 | if(nil == self.titleTipLabel){ 86 | self.titleTipLabel = [[UILabel alloc] init]; 87 | } 88 | 89 | self.titleTipImageView.frame = CGRectMake(-(10/2.0+110/2.0), 0, 110/2.0, 100/2.0); 90 | 91 | 92 | CGFloat ZYX_SCREEN_WIDTH = [[UIScreen mainScreen] bounds].size.width; 93 | CGFloat ZYX_SCREEN_HEIGHT = [[UIScreen mainScreen] bounds].size.height; 94 | 95 | 96 | CGFloat centerX = -ZYX_SCREEN_WIDTH/2.0+self.frame.size.width; 97 | CGFloat centerY = ZYX_SCREEN_HEIGHT/2.0-64; 98 | self.titleTipImageView.center = CGPointMake(centerX, centerY); 99 | 100 | 101 | 102 | self.titleTipImageView.backgroundColor = [UIColor colorWithRed:1/225.0 green:205/255.0 blue:206/255.0 alpha:1]; 103 | self.titleTipImageView.layer.masksToBounds = YES; 104 | self.titleTipImageView.layer.cornerRadius = 4; 105 | 106 | self.titleTipLabel.frame = self.titleTipImageView.bounds; 107 | 108 | 109 | self.titleTipLabel.font = [UIFont systemFontOfSize:17]; 110 | self.titleTipLabel.textAlignment = NSTextAlignmentCenter; 111 | self.titleTipLabel.textColor = [UIColor whiteColor]; 112 | self.titleTipLabel.backgroundColor = [UIColor clearColor]; 113 | [self.titleTipImageView addSubview:self.titleTipLabel]; 114 | 115 | self.titleTipImageView.hidden = YES; 116 | [self addSubview:self.titleTipImageView]; 117 | } 118 | 119 | -(void)setTipViewBackgroundImage:(UIImage *)tipViewBackgroundImage{ 120 | _tipViewBackgroundImage = tipViewBackgroundImage; 121 | self.titleTipImageView.image = _tipViewBackgroundImage; 122 | } 123 | -(void)setTipViewBackgroundColor:(UIColor *)tipViewBackgroundColor{ 124 | _tipViewBackgroundColor = tipViewBackgroundColor; 125 | self.titleTipImageView.backgroundColor = _tipViewBackgroundColor; 126 | } 127 | -(void)setTipViewTitleColor:(UIColor *)tipViewTitleColor{ 128 | _tipViewTitleColor = tipViewTitleColor; 129 | self.titleTipLabel.textColor = _tipViewTitleColor; 130 | } 131 | -(void)setTipViewTitleFont:(UIFont *)tipViewTitleFont{ 132 | _tipViewTitleFont = tipViewTitleFont; 133 | self.titleTipLabel.font = _tipViewTitleFont; 134 | } 135 | -(void)refreshUI{ 136 | if(self.titlesArray.count<=0){ 137 | return; 138 | } 139 | for(UIView * view in self.subviews){ 140 | if([view isKindOfClass:[UILabel class]] && view != self.titleTipLabel){ 141 | [view removeFromSuperview]; 142 | } 143 | } 144 | CGRect selfFrame = self.frame; 145 | selfFrame.size.width = 20; 146 | selfFrame.size.height = (self.titleLabelH+titleLabel_vertical_margin_default)*self.titlesArray.count + 14/2.0; 147 | self.frame = selfFrame; 148 | 149 | //NSLog(@"titleLabelW=%f titleLabelVerticalMargin=%f",self.titleLabelW,self.titleLabelVerticalMargin); 150 | if(nil != self.tableView){ 151 | if(self.frame.size.height>=self.tableView.frame.size.height-10){ 152 | //self.height = self.tableView.height-10; 153 | selfFrame = self.frame; 154 | selfFrame.size.height = self.tableView.frame.size.height-10; 155 | self.frame = selfFrame; 156 | 157 | CGFloat verticalMargin = (self.frame.size.height - self.titleLabelTopMargin)/self.titlesArray.count - self.titleLabelH; 158 | if(verticalMargin14/2.0){ 166 | self.titleLabelVerticalMargin = 14/2.0; 167 | }else{ 168 | self.titleLabelVerticalMargin = titleLabel_vertical_margin_default; 169 | } 170 | selfFrame = self.frame; 171 | selfFrame.size.height = (self.titleLabelH+self.titleLabelVerticalMargin)*self.titlesArray.count + 14/2.0; 172 | self.frame = selfFrame; 173 | } 174 | CGPoint selfCenterPoint = self.center; 175 | selfCenterPoint.y = self.tableView.center.y; 176 | self.center = selfCenterPoint; 177 | } 178 | 179 | 180 | 181 | CGFloat x = 0; 182 | CGFloat y = 0; 183 | CGFloat w = self.titleLabelW; 184 | CGFloat h = self.titleLabelH; 185 | for(int i = 0;i 0){ 216 | label = [self.titleLabelCacheArray lastObject]; 217 | [self.titleLabelCacheArray removeLastObject]; 218 | } 219 | return label; 220 | } 221 | -(void)setIndexTitlesArray:(NSArray*)titlesArray{ 222 | if(nil == self.titlesArray){ 223 | self.titlesArray = [[NSMutableArray alloc] init]; 224 | } 225 | [self.titlesArray removeAllObjects]; 226 | [self.titlesArray addObjectsFromArray:titlesArray]; 227 | 228 | [self.titleLabelCacheArray addObjectsFromArray:self.titleLabelsArray]; 229 | [self.titleLabelsArray removeAllObjects]; 230 | 231 | [self refreshUI]; 232 | } 233 | /* 事件处理 */ 234 | -(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{ 235 | // self.backgroundColor = [UIColor colorWithWhite:0 alpha:0.4]; 236 | //NSLog(@"touchesBegan...%@",NSStringFromClass([self class])); 237 | self.isMoveOutView = NO; 238 | UITouch *touch=[touches anyObject]; 239 | CGPoint location = [touch locationInView:self]; 240 | //NSLog(@"touchesBegan..location = %@",NSStringFromCGPoint(location)); 241 | [self indexTouchedInView:location.y]; 242 | 243 | } 244 | -(void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event{ 245 | self.backgroundColor = [UIColor clearColor]; 246 | //NSLog(@"touchesEnded...%@",NSStringFromClass([self class])); 247 | 248 | UITouch *touch=[touches anyObject]; 249 | CGPoint location = [touch locationInView:self]; 250 | //NSLog(@"touchesEnded..location = %@",NSStringFromCGPoint(location)); 251 | if(!self.isMoveOutView){//点击事件有效 252 | [self indexTouchedInView:location.y]; 253 | }else{//点击事件无效 254 | 255 | } 256 | self.titleTipImageView.hidden = YES; 257 | } 258 | -(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event{ 259 | //NSLog(@"touchesMoved...%@",NSStringFromClass([self class])); 260 | 261 | UITouch *touch=[touches anyObject]; 262 | 263 | CGPoint location = [touch locationInView:self]; 264 | //NSLog(@"touchesMoved..location = %@",NSStringFromCGPoint(location)); 265 | 266 | if (![self pointInside:[touch locationInView:self] withEvent:nil]) { 267 | //NSLog(@"touches moved outside the view"); 268 | self.isMoveOutView = YES; 269 | }else{ 270 | self.isMoveOutView = NO; 271 | UIView *hitView=[self hitTest:[[touches anyObject] locationInView:self] withEvent:nil]; 272 | if (hitView==self){ 273 | //NSLog(@"touches moved in the view"); 274 | }else 275 | { 276 | //NSLog(@"touches moved in the subview"); 277 | } 278 | [self indexTouchedInView:location.y]; 279 | } 280 | } 281 | -(void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event{ 282 | self.backgroundColor = [UIColor clearColor]; 283 | //NSLog(@"touchesCancelled...%@",NSStringFromClass([self class])); 284 | self.titleTipImageView.hidden = YES; 285 | 286 | } 287 | -(NSInteger)indexTouchedInView:(CGFloat)locationY{ 288 | NSInteger index = [self getCurrentLabelWithLoactionY:locationY]; 289 | if(index<0){ 290 | return index; 291 | } 292 | NSString * title = self.titlesArray[index]; 293 | self.titleTipLabel.text = title; 294 | //UILabel * label = self.titleLabelsArray[index]; 295 | //self.titleTipImageView.centerY = label.centerY; 296 | if(self.isShowTipView){ 297 | self.titleTipImageView.hidden = NO; 298 | self.titleTipLabel.hidden = NO; 299 | }else{ 300 | self.titleTipImageView.hidden = YES; 301 | self.titleTipLabel.hidden = YES; 302 | } 303 | 304 | [self tableViewSectionIndexTitle:title atIndex:index]; 305 | return index; 306 | } 307 | 308 | // tableView滚动到对应组 309 | -(void)tableViewSectionIndexTitle:(NSString *)title atIndex:(NSInteger)index{ 310 | NSIndexPath * indexPath = [NSIndexPath indexPathForRow:0 inSection:index]; 311 | if(self.titlesArray.count<=indexPath.row){ 312 | return; 313 | } 314 | if( 0 == indexPath.section){ 315 | CGPoint offset = self.tableView.contentOffset; 316 | offset.y = -self.tableView.contentInset.top; 317 | self.tableView.contentOffset = offset; 318 | }else{ 319 | [self.tableView scrollToRowAtIndexPath:indexPath atScrollPosition:UITableViewScrollPositionTop animated:NO]; 320 | } 321 | } 322 | 323 | -(NSInteger)getCurrentLabelWithLoactionY:(CGFloat)locationY{ 324 | NSInteger index = (locationY - self.titleLabelTopMargin)/(self.titleLabelW+self.titleLabelVerticalMargin); 325 | //NSLog(@"getCurrentLabelWithLoactionY..index = %ld",index); 326 | if(index>=self.titlesArray.count){ 327 | index = self.titlesArray.count - 1; 328 | } 329 | if(index<0){ 330 | index = 0; 331 | } 332 | if(0 == self.titlesArray.count){ 333 | return -1; 334 | } 335 | return index; 336 | } 337 | 338 | @end 339 | -------------------------------------------------------------------------------- /YXCustomIndexView/YXTableViewIndexView/YXTableViewIndexView.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /YXCustomIndexView/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // TBIndexView 4 | // 5 | // Created by 极客天地 on 2017/7/4. 6 | // Copyright © 2017年 极客天地. 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 | --------------------------------------------------------------------------------