├── .gitignore ├── LICENSE ├── LXMLyricsLabel.xcodeproj ├── project.pbxproj └── project.xcworkspace │ └── contents.xcworkspacedata ├── LXMLyricsLabel ├── AppDelegate.h ├── AppDelegate.m ├── Base.lproj │ ├── LaunchScreen.xib │ └── Main.storyboard ├── Images.xcassets │ └── AppIcon.appiconset │ │ └── Contents.json ├── Info.plist ├── LXMLyricsLabel │ ├── LXMBilayerLabel.h │ ├── LXMBilayerLabel.m │ ├── LXMLyricsLabel.h │ └── LXMLyricsLabel.m ├── ViewController.h ├── ViewController.m └── main.m ├── LXMLyricsLabelTests ├── Info.plist └── LXMLyricsLabelTests.m ├── README.md └── ScreenShots └── lxmLyrics2.gif /.gitignore: -------------------------------------------------------------------------------- 1 | # Xcode 2 | # 3 | build/ 4 | *.pbxuser 5 | !default.pbxuser 6 | *.mode1v3 7 | !default.mode1v3 8 | *.mode2v3 9 | !default.mode2v3 10 | *.perspectivev3 11 | !default.perspectivev3 12 | xcuserdata 13 | *.xccheckout 14 | *.moved-aside 15 | DerivedData 16 | *.hmap 17 | *.ipa 18 | *.xcuserstate 19 | 20 | # CocoaPods 21 | # 22 | # We recommend against adding the Pods directory to your .gitignore. However 23 | # you should judge for yourself, the pros and cons are mentioned at: 24 | # http://guides.cocoapods.org/using/using-cocoapods.html#should-i-ignore-the-pods-directory-in-source-control 25 | # 26 | #Pods/ 27 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 luxiaoming 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 | 23 | -------------------------------------------------------------------------------- /LXMLyricsLabel.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 43A463FE1B9E784C00F732FC /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 43A463FD1B9E784C00F732FC /* main.m */; }; 11 | 43A464011B9E784C00F732FC /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 43A464001B9E784C00F732FC /* AppDelegate.m */; }; 12 | 43A464041B9E784C00F732FC /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 43A464031B9E784C00F732FC /* ViewController.m */; }; 13 | 43A464071B9E784C00F732FC /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 43A464051B9E784C00F732FC /* Main.storyboard */; }; 14 | 43A464091B9E784C00F732FC /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 43A464081B9E784C00F732FC /* Images.xcassets */; }; 15 | 43A4640C1B9E784C00F732FC /* LaunchScreen.xib in Resources */ = {isa = PBXBuildFile; fileRef = 43A4640A1B9E784C00F732FC /* LaunchScreen.xib */; }; 16 | 43A464181B9E784C00F732FC /* LXMLyricsLabelTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 43A464171B9E784C00F732FC /* LXMLyricsLabelTests.m */; }; 17 | 43A464241B9E788C00F732FC /* LXMLyricsLabel.m in Sources */ = {isa = PBXBuildFile; fileRef = 43A464231B9E788C00F732FC /* LXMLyricsLabel.m */; }; 18 | 43BC063B1BA674F8006EA05A /* LXMBilayerLabel.m in Sources */ = {isa = PBXBuildFile; fileRef = 43BC063A1BA674F8006EA05A /* LXMBilayerLabel.m */; }; 19 | /* End PBXBuildFile section */ 20 | 21 | /* Begin PBXContainerItemProxy section */ 22 | 43A464121B9E784C00F732FC /* PBXContainerItemProxy */ = { 23 | isa = PBXContainerItemProxy; 24 | containerPortal = 43A463F01B9E784C00F732FC /* Project object */; 25 | proxyType = 1; 26 | remoteGlobalIDString = 43A463F71B9E784C00F732FC; 27 | remoteInfo = LXMLyricsLabel; 28 | }; 29 | /* End PBXContainerItemProxy section */ 30 | 31 | /* Begin PBXFileReference section */ 32 | 43A463F81B9E784C00F732FC /* LXMLyricsLabel.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = LXMLyricsLabel.app; sourceTree = BUILT_PRODUCTS_DIR; }; 33 | 43A463FC1B9E784C00F732FC /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 34 | 43A463FD1B9E784C00F732FC /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 35 | 43A463FF1B9E784C00F732FC /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; 36 | 43A464001B9E784C00F732FC /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; 37 | 43A464021B9E784C00F732FC /* ViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = ""; }; 38 | 43A464031B9E784C00F732FC /* ViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = ""; }; 39 | 43A464061B9E784C00F732FC /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 40 | 43A464081B9E784C00F732FC /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = ""; }; 41 | 43A4640B1B9E784C00F732FC /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/LaunchScreen.xib; sourceTree = ""; }; 42 | 43A464111B9E784C00F732FC /* LXMLyricsLabelTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = LXMLyricsLabelTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 43 | 43A464161B9E784C00F732FC /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 44 | 43A464171B9E784C00F732FC /* LXMLyricsLabelTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = LXMLyricsLabelTests.m; sourceTree = ""; }; 45 | 43A464221B9E788C00F732FC /* LXMLyricsLabel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LXMLyricsLabel.h; sourceTree = ""; }; 46 | 43A464231B9E788C00F732FC /* LXMLyricsLabel.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LXMLyricsLabel.m; sourceTree = ""; }; 47 | 43BC06391BA674F8006EA05A /* LXMBilayerLabel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LXMBilayerLabel.h; sourceTree = ""; }; 48 | 43BC063A1BA674F8006EA05A /* LXMBilayerLabel.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LXMBilayerLabel.m; sourceTree = ""; }; 49 | /* End PBXFileReference section */ 50 | 51 | /* Begin PBXFrameworksBuildPhase section */ 52 | 43A463F51B9E784C00F732FC /* Frameworks */ = { 53 | isa = PBXFrameworksBuildPhase; 54 | buildActionMask = 2147483647; 55 | files = ( 56 | ); 57 | runOnlyForDeploymentPostprocessing = 0; 58 | }; 59 | 43A4640E1B9E784C00F732FC /* Frameworks */ = { 60 | isa = PBXFrameworksBuildPhase; 61 | buildActionMask = 2147483647; 62 | files = ( 63 | ); 64 | runOnlyForDeploymentPostprocessing = 0; 65 | }; 66 | /* End PBXFrameworksBuildPhase section */ 67 | 68 | /* Begin PBXGroup section */ 69 | 43A463EF1B9E784C00F732FC = { 70 | isa = PBXGroup; 71 | children = ( 72 | 43A463FA1B9E784C00F732FC /* LXMLyricsLabel */, 73 | 43A464141B9E784C00F732FC /* LXMLyricsLabelTests */, 74 | 43A463F91B9E784C00F732FC /* Products */, 75 | ); 76 | sourceTree = ""; 77 | }; 78 | 43A463F91B9E784C00F732FC /* Products */ = { 79 | isa = PBXGroup; 80 | children = ( 81 | 43A463F81B9E784C00F732FC /* LXMLyricsLabel.app */, 82 | 43A464111B9E784C00F732FC /* LXMLyricsLabelTests.xctest */, 83 | ); 84 | name = Products; 85 | sourceTree = ""; 86 | }; 87 | 43A463FA1B9E784C00F732FC /* LXMLyricsLabel */ = { 88 | isa = PBXGroup; 89 | children = ( 90 | 43A464211B9E787500F732FC /* LXMLyricsLabel */, 91 | 43A463FF1B9E784C00F732FC /* AppDelegate.h */, 92 | 43A464001B9E784C00F732FC /* AppDelegate.m */, 93 | 43A464021B9E784C00F732FC /* ViewController.h */, 94 | 43A464031B9E784C00F732FC /* ViewController.m */, 95 | 43A464051B9E784C00F732FC /* Main.storyboard */, 96 | 43A464081B9E784C00F732FC /* Images.xcassets */, 97 | 43A4640A1B9E784C00F732FC /* LaunchScreen.xib */, 98 | 43A463FB1B9E784C00F732FC /* Supporting Files */, 99 | ); 100 | path = LXMLyricsLabel; 101 | sourceTree = ""; 102 | }; 103 | 43A463FB1B9E784C00F732FC /* Supporting Files */ = { 104 | isa = PBXGroup; 105 | children = ( 106 | 43A463FC1B9E784C00F732FC /* Info.plist */, 107 | 43A463FD1B9E784C00F732FC /* main.m */, 108 | ); 109 | name = "Supporting Files"; 110 | sourceTree = ""; 111 | }; 112 | 43A464141B9E784C00F732FC /* LXMLyricsLabelTests */ = { 113 | isa = PBXGroup; 114 | children = ( 115 | 43A464171B9E784C00F732FC /* LXMLyricsLabelTests.m */, 116 | 43A464151B9E784C00F732FC /* Supporting Files */, 117 | ); 118 | path = LXMLyricsLabelTests; 119 | sourceTree = ""; 120 | }; 121 | 43A464151B9E784C00F732FC /* Supporting Files */ = { 122 | isa = PBXGroup; 123 | children = ( 124 | 43A464161B9E784C00F732FC /* Info.plist */, 125 | ); 126 | name = "Supporting Files"; 127 | sourceTree = ""; 128 | }; 129 | 43A464211B9E787500F732FC /* LXMLyricsLabel */ = { 130 | isa = PBXGroup; 131 | children = ( 132 | 43A464221B9E788C00F732FC /* LXMLyricsLabel.h */, 133 | 43A464231B9E788C00F732FC /* LXMLyricsLabel.m */, 134 | 43BC06391BA674F8006EA05A /* LXMBilayerLabel.h */, 135 | 43BC063A1BA674F8006EA05A /* LXMBilayerLabel.m */, 136 | ); 137 | path = LXMLyricsLabel; 138 | sourceTree = ""; 139 | }; 140 | /* End PBXGroup section */ 141 | 142 | /* Begin PBXNativeTarget section */ 143 | 43A463F71B9E784C00F732FC /* LXMLyricsLabel */ = { 144 | isa = PBXNativeTarget; 145 | buildConfigurationList = 43A4641B1B9E784C00F732FC /* Build configuration list for PBXNativeTarget "LXMLyricsLabel" */; 146 | buildPhases = ( 147 | 43A463F41B9E784C00F732FC /* Sources */, 148 | 43A463F51B9E784C00F732FC /* Frameworks */, 149 | 43A463F61B9E784C00F732FC /* Resources */, 150 | ); 151 | buildRules = ( 152 | ); 153 | dependencies = ( 154 | ); 155 | name = LXMLyricsLabel; 156 | productName = LXMLyricsLabel; 157 | productReference = 43A463F81B9E784C00F732FC /* LXMLyricsLabel.app */; 158 | productType = "com.apple.product-type.application"; 159 | }; 160 | 43A464101B9E784C00F732FC /* LXMLyricsLabelTests */ = { 161 | isa = PBXNativeTarget; 162 | buildConfigurationList = 43A4641E1B9E784C00F732FC /* Build configuration list for PBXNativeTarget "LXMLyricsLabelTests" */; 163 | buildPhases = ( 164 | 43A4640D1B9E784C00F732FC /* Sources */, 165 | 43A4640E1B9E784C00F732FC /* Frameworks */, 166 | 43A4640F1B9E784C00F732FC /* Resources */, 167 | ); 168 | buildRules = ( 169 | ); 170 | dependencies = ( 171 | 43A464131B9E784C00F732FC /* PBXTargetDependency */, 172 | ); 173 | name = LXMLyricsLabelTests; 174 | productName = LXMLyricsLabelTests; 175 | productReference = 43A464111B9E784C00F732FC /* LXMLyricsLabelTests.xctest */; 176 | productType = "com.apple.product-type.bundle.unit-test"; 177 | }; 178 | /* End PBXNativeTarget section */ 179 | 180 | /* Begin PBXProject section */ 181 | 43A463F01B9E784C00F732FC /* Project object */ = { 182 | isa = PBXProject; 183 | attributes = { 184 | LastUpgradeCheck = 0630; 185 | ORGANIZATIONNAME = luxiaoming; 186 | TargetAttributes = { 187 | 43A463F71B9E784C00F732FC = { 188 | CreatedOnToolsVersion = 6.3; 189 | }; 190 | 43A464101B9E784C00F732FC = { 191 | CreatedOnToolsVersion = 6.3; 192 | TestTargetID = 43A463F71B9E784C00F732FC; 193 | }; 194 | }; 195 | }; 196 | buildConfigurationList = 43A463F31B9E784C00F732FC /* Build configuration list for PBXProject "LXMLyricsLabel" */; 197 | compatibilityVersion = "Xcode 3.2"; 198 | developmentRegion = English; 199 | hasScannedForEncodings = 0; 200 | knownRegions = ( 201 | en, 202 | Base, 203 | ); 204 | mainGroup = 43A463EF1B9E784C00F732FC; 205 | productRefGroup = 43A463F91B9E784C00F732FC /* Products */; 206 | projectDirPath = ""; 207 | projectRoot = ""; 208 | targets = ( 209 | 43A463F71B9E784C00F732FC /* LXMLyricsLabel */, 210 | 43A464101B9E784C00F732FC /* LXMLyricsLabelTests */, 211 | ); 212 | }; 213 | /* End PBXProject section */ 214 | 215 | /* Begin PBXResourcesBuildPhase section */ 216 | 43A463F61B9E784C00F732FC /* Resources */ = { 217 | isa = PBXResourcesBuildPhase; 218 | buildActionMask = 2147483647; 219 | files = ( 220 | 43A464071B9E784C00F732FC /* Main.storyboard in Resources */, 221 | 43A4640C1B9E784C00F732FC /* LaunchScreen.xib in Resources */, 222 | 43A464091B9E784C00F732FC /* Images.xcassets in Resources */, 223 | ); 224 | runOnlyForDeploymentPostprocessing = 0; 225 | }; 226 | 43A4640F1B9E784C00F732FC /* Resources */ = { 227 | isa = PBXResourcesBuildPhase; 228 | buildActionMask = 2147483647; 229 | files = ( 230 | ); 231 | runOnlyForDeploymentPostprocessing = 0; 232 | }; 233 | /* End PBXResourcesBuildPhase section */ 234 | 235 | /* Begin PBXSourcesBuildPhase section */ 236 | 43A463F41B9E784C00F732FC /* Sources */ = { 237 | isa = PBXSourcesBuildPhase; 238 | buildActionMask = 2147483647; 239 | files = ( 240 | 43A464041B9E784C00F732FC /* ViewController.m in Sources */, 241 | 43A464011B9E784C00F732FC /* AppDelegate.m in Sources */, 242 | 43A464241B9E788C00F732FC /* LXMLyricsLabel.m in Sources */, 243 | 43BC063B1BA674F8006EA05A /* LXMBilayerLabel.m in Sources */, 244 | 43A463FE1B9E784C00F732FC /* main.m in Sources */, 245 | ); 246 | runOnlyForDeploymentPostprocessing = 0; 247 | }; 248 | 43A4640D1B9E784C00F732FC /* Sources */ = { 249 | isa = PBXSourcesBuildPhase; 250 | buildActionMask = 2147483647; 251 | files = ( 252 | 43A464181B9E784C00F732FC /* LXMLyricsLabelTests.m in Sources */, 253 | ); 254 | runOnlyForDeploymentPostprocessing = 0; 255 | }; 256 | /* End PBXSourcesBuildPhase section */ 257 | 258 | /* Begin PBXTargetDependency section */ 259 | 43A464131B9E784C00F732FC /* PBXTargetDependency */ = { 260 | isa = PBXTargetDependency; 261 | target = 43A463F71B9E784C00F732FC /* LXMLyricsLabel */; 262 | targetProxy = 43A464121B9E784C00F732FC /* PBXContainerItemProxy */; 263 | }; 264 | /* End PBXTargetDependency section */ 265 | 266 | /* Begin PBXVariantGroup section */ 267 | 43A464051B9E784C00F732FC /* Main.storyboard */ = { 268 | isa = PBXVariantGroup; 269 | children = ( 270 | 43A464061B9E784C00F732FC /* Base */, 271 | ); 272 | name = Main.storyboard; 273 | sourceTree = ""; 274 | }; 275 | 43A4640A1B9E784C00F732FC /* LaunchScreen.xib */ = { 276 | isa = PBXVariantGroup; 277 | children = ( 278 | 43A4640B1B9E784C00F732FC /* Base */, 279 | ); 280 | name = LaunchScreen.xib; 281 | sourceTree = ""; 282 | }; 283 | /* End PBXVariantGroup section */ 284 | 285 | /* Begin XCBuildConfiguration section */ 286 | 43A464191B9E784C00F732FC /* Debug */ = { 287 | isa = XCBuildConfiguration; 288 | buildSettings = { 289 | ALWAYS_SEARCH_USER_PATHS = NO; 290 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 291 | CLANG_CXX_LIBRARY = "libc++"; 292 | CLANG_ENABLE_MODULES = YES; 293 | CLANG_ENABLE_OBJC_ARC = YES; 294 | CLANG_WARN_BOOL_CONVERSION = YES; 295 | CLANG_WARN_CONSTANT_CONVERSION = YES; 296 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 297 | CLANG_WARN_EMPTY_BODY = YES; 298 | CLANG_WARN_ENUM_CONVERSION = YES; 299 | CLANG_WARN_INT_CONVERSION = YES; 300 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 301 | CLANG_WARN_UNREACHABLE_CODE = YES; 302 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 303 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 304 | COPY_PHASE_STRIP = NO; 305 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 306 | ENABLE_STRICT_OBJC_MSGSEND = YES; 307 | GCC_C_LANGUAGE_STANDARD = gnu99; 308 | GCC_DYNAMIC_NO_PIC = NO; 309 | GCC_NO_COMMON_BLOCKS = YES; 310 | GCC_OPTIMIZATION_LEVEL = 0; 311 | GCC_PREPROCESSOR_DEFINITIONS = ( 312 | "DEBUG=1", 313 | "$(inherited)", 314 | ); 315 | GCC_SYMBOLS_PRIVATE_EXTERN = NO; 316 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 317 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 318 | GCC_WARN_UNDECLARED_SELECTOR = YES; 319 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 320 | GCC_WARN_UNUSED_FUNCTION = YES; 321 | GCC_WARN_UNUSED_VARIABLE = YES; 322 | IPHONEOS_DEPLOYMENT_TARGET = 8.3; 323 | MTL_ENABLE_DEBUG_INFO = YES; 324 | ONLY_ACTIVE_ARCH = YES; 325 | SDKROOT = iphoneos; 326 | }; 327 | name = Debug; 328 | }; 329 | 43A4641A1B9E784C00F732FC /* Release */ = { 330 | isa = XCBuildConfiguration; 331 | buildSettings = { 332 | ALWAYS_SEARCH_USER_PATHS = NO; 333 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 334 | CLANG_CXX_LIBRARY = "libc++"; 335 | CLANG_ENABLE_MODULES = YES; 336 | CLANG_ENABLE_OBJC_ARC = YES; 337 | CLANG_WARN_BOOL_CONVERSION = YES; 338 | CLANG_WARN_CONSTANT_CONVERSION = YES; 339 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 340 | CLANG_WARN_EMPTY_BODY = YES; 341 | CLANG_WARN_ENUM_CONVERSION = YES; 342 | CLANG_WARN_INT_CONVERSION = YES; 343 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 344 | CLANG_WARN_UNREACHABLE_CODE = YES; 345 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 346 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 347 | COPY_PHASE_STRIP = NO; 348 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 349 | ENABLE_NS_ASSERTIONS = NO; 350 | ENABLE_STRICT_OBJC_MSGSEND = YES; 351 | GCC_C_LANGUAGE_STANDARD = gnu99; 352 | GCC_NO_COMMON_BLOCKS = YES; 353 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 354 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 355 | GCC_WARN_UNDECLARED_SELECTOR = YES; 356 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 357 | GCC_WARN_UNUSED_FUNCTION = YES; 358 | GCC_WARN_UNUSED_VARIABLE = YES; 359 | IPHONEOS_DEPLOYMENT_TARGET = 8.3; 360 | MTL_ENABLE_DEBUG_INFO = NO; 361 | SDKROOT = iphoneos; 362 | VALIDATE_PRODUCT = YES; 363 | }; 364 | name = Release; 365 | }; 366 | 43A4641C1B9E784C00F732FC /* Debug */ = { 367 | isa = XCBuildConfiguration; 368 | buildSettings = { 369 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 370 | INFOPLIST_FILE = LXMLyricsLabel/Info.plist; 371 | IPHONEOS_DEPLOYMENT_TARGET = 7.0; 372 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 373 | PRODUCT_NAME = "$(TARGET_NAME)"; 374 | }; 375 | name = Debug; 376 | }; 377 | 43A4641D1B9E784C00F732FC /* Release */ = { 378 | isa = XCBuildConfiguration; 379 | buildSettings = { 380 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 381 | INFOPLIST_FILE = LXMLyricsLabel/Info.plist; 382 | IPHONEOS_DEPLOYMENT_TARGET = 7.0; 383 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 384 | PRODUCT_NAME = "$(TARGET_NAME)"; 385 | }; 386 | name = Release; 387 | }; 388 | 43A4641F1B9E784C00F732FC /* Debug */ = { 389 | isa = XCBuildConfiguration; 390 | buildSettings = { 391 | BUNDLE_LOADER = "$(TEST_HOST)"; 392 | FRAMEWORK_SEARCH_PATHS = ( 393 | "$(SDKROOT)/Developer/Library/Frameworks", 394 | "$(inherited)", 395 | ); 396 | GCC_PREPROCESSOR_DEFINITIONS = ( 397 | "DEBUG=1", 398 | "$(inherited)", 399 | ); 400 | INFOPLIST_FILE = LXMLyricsLabelTests/Info.plist; 401 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 402 | PRODUCT_NAME = "$(TARGET_NAME)"; 403 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/LXMLyricsLabel.app/LXMLyricsLabel"; 404 | }; 405 | name = Debug; 406 | }; 407 | 43A464201B9E784C00F732FC /* Release */ = { 408 | isa = XCBuildConfiguration; 409 | buildSettings = { 410 | BUNDLE_LOADER = "$(TEST_HOST)"; 411 | FRAMEWORK_SEARCH_PATHS = ( 412 | "$(SDKROOT)/Developer/Library/Frameworks", 413 | "$(inherited)", 414 | ); 415 | INFOPLIST_FILE = LXMLyricsLabelTests/Info.plist; 416 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 417 | PRODUCT_NAME = "$(TARGET_NAME)"; 418 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/LXMLyricsLabel.app/LXMLyricsLabel"; 419 | }; 420 | name = Release; 421 | }; 422 | /* End XCBuildConfiguration section */ 423 | 424 | /* Begin XCConfigurationList section */ 425 | 43A463F31B9E784C00F732FC /* Build configuration list for PBXProject "LXMLyricsLabel" */ = { 426 | isa = XCConfigurationList; 427 | buildConfigurations = ( 428 | 43A464191B9E784C00F732FC /* Debug */, 429 | 43A4641A1B9E784C00F732FC /* Release */, 430 | ); 431 | defaultConfigurationIsVisible = 0; 432 | defaultConfigurationName = Release; 433 | }; 434 | 43A4641B1B9E784C00F732FC /* Build configuration list for PBXNativeTarget "LXMLyricsLabel" */ = { 435 | isa = XCConfigurationList; 436 | buildConfigurations = ( 437 | 43A4641C1B9E784C00F732FC /* Debug */, 438 | 43A4641D1B9E784C00F732FC /* Release */, 439 | ); 440 | defaultConfigurationIsVisible = 0; 441 | defaultConfigurationName = Release; 442 | }; 443 | 43A4641E1B9E784C00F732FC /* Build configuration list for PBXNativeTarget "LXMLyricsLabelTests" */ = { 444 | isa = XCConfigurationList; 445 | buildConfigurations = ( 446 | 43A4641F1B9E784C00F732FC /* Debug */, 447 | 43A464201B9E784C00F732FC /* Release */, 448 | ); 449 | defaultConfigurationIsVisible = 0; 450 | defaultConfigurationName = Release; 451 | }; 452 | /* End XCConfigurationList section */ 453 | }; 454 | rootObject = 43A463F01B9E784C00F732FC /* Project object */; 455 | } 456 | -------------------------------------------------------------------------------- /LXMLyricsLabel.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /LXMLyricsLabel/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // LXMLyricsLabel 4 | // 5 | // Created by luxiaoming on 15/9/8. 6 | // Copyright (c) 2015年 luxiaoming. 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 | -------------------------------------------------------------------------------- /LXMLyricsLabel/AppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.m 3 | // LXMLyricsLabel 4 | // 5 | // Created by luxiaoming on 15/9/8. 6 | // Copyright (c) 2015年 luxiaoming. 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 | - (void)applicationWillResignActive:(UIApplication *)application { 24 | // 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. 25 | // 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. 26 | } 27 | 28 | - (void)applicationDidEnterBackground:(UIApplication *)application { 29 | // 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. 30 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 31 | } 32 | 33 | - (void)applicationWillEnterForeground:(UIApplication *)application { 34 | // 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. 35 | } 36 | 37 | - (void)applicationDidBecomeActive:(UIApplication *)application { 38 | // 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. 39 | } 40 | 41 | - (void)applicationWillTerminate:(UIApplication *)application { 42 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 43 | } 44 | 45 | @end 46 | -------------------------------------------------------------------------------- /LXMLyricsLabel/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 | -------------------------------------------------------------------------------- /LXMLyricsLabel/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 | -------------------------------------------------------------------------------- /LXMLyricsLabel/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 | } -------------------------------------------------------------------------------- /LXMLyricsLabel/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | com.ouj.$(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 | -------------------------------------------------------------------------------- /LXMLyricsLabel/LXMLyricsLabel/LXMBilayerLabel.h: -------------------------------------------------------------------------------- 1 | // 2 | // LXMBilayerLabel.h 3 | // LXMLyricsLabel 4 | // 5 | // Created by luxiaoming on 15/9/14. 6 | // Copyright (c) 2015年 luxiaoming. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface LXMBilayerLabel : UIView 12 | 13 | @property (nonatomic, strong, readonly) UILabel *textLabel; 14 | @property (nonatomic, strong, readonly) UILabel *maskLabel; 15 | 16 | - (void)setFont:(UIFont *)font; 17 | 18 | - (void)setText:(NSString *)text; 19 | 20 | - (void)setTextAlignment:(NSTextAlignment)textAlignment; 21 | 22 | 23 | - (void)startAnimation; 24 | 25 | - (void)stopAnimation; 26 | 27 | @end 28 | -------------------------------------------------------------------------------- /LXMLyricsLabel/LXMLyricsLabel/LXMBilayerLabel.m: -------------------------------------------------------------------------------- 1 | // 2 | // LXMBilayerLabel.m 3 | // LXMLyricsLabel 4 | // 5 | // Created by luxiaoming on 15/9/14. 6 | // Copyright (c) 2015年 luxiaoming. All rights reserved. 7 | // 8 | 9 | #import "LXMBilayerLabel.h" 10 | 11 | @interface LXMBilayerLabel () 12 | 13 | @property (nonatomic, strong, readwrite) UILabel *textLabel; 14 | @property (nonatomic, strong, readwrite) UILabel *maskLabel; 15 | @property (nonatomic, strong) CALayer *maskLayer;//用来控制maskLabel渲染的layer 16 | 17 | @property (nonatomic, strong) UIColor *maskTextColor; 18 | @property (nonatomic, strong) UIColor *maskBackgroundColor; 19 | 20 | @end 21 | 22 | @implementation LXMBilayerLabel 23 | 24 | - (instancetype)initWithFrame:(CGRect)frame { 25 | self = [super initWithFrame:frame]; 26 | if (self) { 27 | [self addSubview:self.textLabel]; 28 | [self addSubview:self.maskLabel]; 29 | [self setupDefault]; 30 | } 31 | return self; 32 | } 33 | 34 | - (void)setupDefault { 35 | self.maskTextColor = [UIColor orangeColor]; 36 | self.maskBackgroundColor = [UIColor clearColor]; 37 | 38 | self.maskLabel.textColor = self.maskTextColor; 39 | self.maskLabel.backgroundColor = self.maskBackgroundColor; 40 | 41 | CAGradientLayer *maskLayer = [CAGradientLayer layer]; 42 | maskLayer.position = CGPointMake(-CGRectGetWidth(self.bounds)/2, CGRectGetHeight(self.bounds) / 2); 43 | maskLayer.bounds = self.bounds; 44 | maskLayer.colors = @[(id)[UIColor clearColor].CGColor, 45 | (id)[UIColor whiteColor].CGColor, 46 | (id)[UIColor clearColor].CGColor,]; 47 | maskLayer.startPoint = CGPointMake(0, 0.5); 48 | maskLayer.endPoint = CGPointMake(1, 0.5); 49 | self.maskLabel.layer.mask = maskLayer; 50 | // [self.maskLabel.layer addSublayer:maskLayer]; 51 | self.maskLayer = maskLayer; 52 | 53 | 54 | } 55 | 56 | #pragma mark - publicMethod 57 | 58 | - (void)startAnimation { 59 | CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:@"position.x"]; 60 | animation.toValue = @(CGRectGetWidth(self.bounds) / 2 * 3); 61 | animation.duration = 2; 62 | // animation.fillMode = kCAFillModeForwards; 63 | // animation.removedOnCompletion = NO; 64 | animation.repeatCount = NSIntegerMax; 65 | [self.maskLayer addAnimation:animation forKey:@"kLXMShimmerAnimation"]; 66 | } 67 | 68 | - (void)stopAnimation { 69 | [self.maskLayer removeAllAnimations]; 70 | } 71 | 72 | 73 | #pragma mark - setter 74 | 75 | - (void)setText:(NSString *)text { 76 | self.textLabel.text = text; 77 | self.maskLabel.text = text; 78 | } 79 | 80 | - (void)setFont:(UIFont *)font { 81 | self.textLabel.font = font; 82 | self.maskLabel.font = font; 83 | } 84 | 85 | - (void)setTextAlignment:(NSTextAlignment)textAlignment { 86 | self.textLabel.textAlignment = textAlignment; 87 | [self.maskLabel setTextAlignment:textAlignment]; 88 | } 89 | 90 | 91 | 92 | 93 | 94 | #pragma mark - property 95 | 96 | - (UILabel *)textLabel { 97 | if (!_textLabel) { 98 | _textLabel = [[UILabel alloc] initWithFrame:self.bounds]; 99 | } 100 | return _textLabel; 101 | } 102 | 103 | - (UILabel *)maskLabel { 104 | if (!_maskLabel) { 105 | _maskLabel = [[UILabel alloc] initWithFrame:self.bounds]; 106 | } 107 | return _maskLabel; 108 | } 109 | 110 | @end 111 | -------------------------------------------------------------------------------- /LXMLyricsLabel/LXMLyricsLabel/LXMLyricsLabel.h: -------------------------------------------------------------------------------- 1 | // 2 | // LXMLyricsLabel.h 3 | // LXMLyricsLabel 4 | // 5 | // Created by luxiaoming on 15/9/8. 6 | // Copyright (c) 2015年 luxiaoming. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface LXMLyricsLabel : UIView 12 | 13 | @property (nonatomic, strong, readonly) UILabel *textLabel; 14 | @property (nonatomic, strong, readonly) UILabel *maskLabel; 15 | 16 | 17 | - (void)setFont:(UIFont *)font; 18 | 19 | - (void)setText:(NSString *)text; 20 | 21 | - (void)setTextAlignment:(NSTextAlignment)textAlignment; 22 | 23 | /** 24 | * 根据设置显示动画 25 | * 26 | * @param timeArray 数组的内容是各个时间点,第一个必须是0,最后一个必须是总时间 27 | * @param locationArray 对应各个时间点的位置,值从0~1,第一个必须是0,最后一个必须是1 28 | */ 29 | - (void)startLyricsAnimationWithTimeArray:(NSArray *)timeArray andLocationArray:(NSArray *)locationArray; 30 | 31 | - (void)stopAnimation; 32 | 33 | @end 34 | -------------------------------------------------------------------------------- /LXMLyricsLabel/LXMLyricsLabel/LXMLyricsLabel.m: -------------------------------------------------------------------------------- 1 | // 2 | // LXMLyricsLabel.m 3 | // LXMLyricsLabel 4 | // 5 | // Created by luxiaoming on 15/9/8. 6 | // Copyright (c) 2015年 luxiaoming. All rights reserved. 7 | // 8 | 9 | #import "LXMLyricsLabel.h" 10 | 11 | @interface LXMLyricsLabel () 12 | 13 | @property (nonatomic, strong, readwrite) UILabel *textLabel; 14 | @property (nonatomic, strong, readwrite) UILabel *maskLabel; 15 | @property (nonatomic, strong) CALayer *maskLayer;//用来控制maskLabel渲染的layer 16 | 17 | @property (nonatomic, strong) UIColor *maskTextColor; 18 | @property (nonatomic, strong) UIColor *maskBackgroundColor; 19 | 20 | @end 21 | 22 | @implementation LXMLyricsLabel 23 | 24 | - (instancetype)initWithFrame:(CGRect)frame { 25 | self = [super initWithFrame:frame]; 26 | if (self) { 27 | [self addSubview:self.textLabel]; 28 | [self addSubview:self.maskLabel]; 29 | [self setupDefault]; 30 | } 31 | return self; 32 | } 33 | 34 | - (void)setupDefault { 35 | self.maskTextColor = [UIColor orangeColor]; 36 | self.maskBackgroundColor = [UIColor clearColor]; 37 | 38 | self.maskLabel.textColor = self.maskTextColor; 39 | self.maskLabel.backgroundColor = self.maskBackgroundColor; 40 | 41 | CALayer *maskLayer = [CALayer layer]; 42 | maskLayer.anchorPoint = CGPointMake(0, 0.5);//注意,按默认的anchorPoint,width动画是同时像左右扩展的 43 | maskLayer.position = CGPointMake(0, CGRectGetHeight(self.bounds) / 2); 44 | maskLayer.bounds = CGRectMake(0, 0, 0, CGRectGetHeight(self.bounds)); 45 | maskLayer.backgroundColor = [UIColor whiteColor].CGColor; 46 | self.maskLabel.layer.mask = maskLayer; 47 | self.maskLayer = maskLayer; 48 | 49 | 50 | } 51 | 52 | #pragma mark - publicMethod 53 | 54 | 55 | - (void)setFont:(UIFont *)font { 56 | self.textLabel.font = font; 57 | self.maskLabel.font = font; 58 | } 59 | 60 | - (void)setText:(NSString *)text { 61 | self.textLabel.text = text; 62 | self.maskLabel.text = text; 63 | } 64 | 65 | - (void)setTextAlignment:(NSTextAlignment)textAlignment { 66 | self.textLabel.textAlignment = textAlignment; 67 | self.maskLabel.textAlignment = textAlignment; 68 | } 69 | 70 | 71 | - (void)startLyricsAnimationWithTimeArray:(NSArray *)timeArray andLocationArray:(NSArray *)locationArray { 72 | 73 | CGFloat totalDuration = [timeArray.lastObject floatValue]; 74 | 75 | CAKeyframeAnimation *animation = [CAKeyframeAnimation animationWithKeyPath:@"bounds.size.width"]; 76 | NSMutableArray *keyTimeArray = [NSMutableArray array]; 77 | NSMutableArray *widthArray = [NSMutableArray array]; 78 | for (int i = 0 ; i < timeArray.count; i++) { 79 | CGFloat tempTime = [timeArray[i] floatValue] / totalDuration; 80 | [keyTimeArray addObject:@(tempTime)]; 81 | CGFloat tempWidth = [locationArray[i] floatValue] * CGRectGetWidth(self.bounds); 82 | [widthArray addObject:@(tempWidth)]; 83 | } 84 | 85 | animation.values = widthArray; 86 | animation.keyTimes = keyTimeArray; 87 | animation.duration = totalDuration; 88 | animation.calculationMode = kCAAnimationLinear; 89 | animation.fillMode = kCAFillModeForwards; 90 | animation.removedOnCompletion = NO; 91 | [self.maskLayer addAnimation:animation forKey:@"kLyrcisAnimation"]; 92 | } 93 | 94 | - (void)stopAnimation { 95 | [self.maskLayer removeAllAnimations]; 96 | } 97 | 98 | 99 | #pragma mark - property 100 | 101 | - (UILabel *)textLabel { 102 | if (!_textLabel) { 103 | _textLabel = [[UILabel alloc] initWithFrame:self.bounds]; 104 | } 105 | return _textLabel; 106 | } 107 | 108 | - (UILabel *)maskLabel { 109 | if (!_maskLabel) { 110 | _maskLabel = [[UILabel alloc] initWithFrame:self.bounds]; 111 | } 112 | return _maskLabel; 113 | } 114 | 115 | @end 116 | -------------------------------------------------------------------------------- /LXMLyricsLabel/ViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.h 3 | // LXMLyricsLabel 4 | // 5 | // Created by luxiaoming on 15/9/8. 6 | // Copyright (c) 2015年 luxiaoming. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface ViewController : UIViewController 12 | 13 | 14 | @end 15 | 16 | -------------------------------------------------------------------------------- /LXMLyricsLabel/ViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.m 3 | // LXMLyricsLabel 4 | // 5 | // Created by luxiaoming on 15/9/8. 6 | // Copyright (c) 2015年 luxiaoming. All rights reserved. 7 | // 8 | 9 | #import "ViewController.h" 10 | #import "LXMLyricsLabel.h" 11 | #import "LXMBilayerLabel.h" 12 | 13 | @interface ViewController () 14 | 15 | @property (nonatomic, strong) LXMLyricsLabel *lyricsLabel; 16 | @property (nonatomic, strong) LXMBilayerLabel *bilayerLabel; 17 | 18 | @end 19 | 20 | @implementation ViewController 21 | 22 | - (void)viewDidLoad { 23 | [super viewDidLoad]; 24 | // Do any additional setup after loading the view, typically from a nib. 25 | LXMLyricsLabel *lyricsLabel = [[LXMLyricsLabel alloc] initWithFrame:CGRectMake(100, 100, 200, 20)]; 26 | lyricsLabel.center = CGPointMake(CGRectGetWidth([UIScreen mainScreen].bounds) / 2, 200); 27 | lyricsLabel.backgroundColor = [UIColor lightGrayColor]; 28 | lyricsLabel.textLabel.textColor = [UIColor whiteColor]; 29 | lyricsLabel.font = [UIFont systemFontOfSize:14]; 30 | lyricsLabel.text = @"向前跑!迎着冷眼和嘲笑";//@"knocking on heaven's door"; 31 | lyricsLabel.textAlignment = NSTextAlignmentCenter; 32 | [self.view addSubview:lyricsLabel]; 33 | self.lyricsLabel = lyricsLabel; 34 | 35 | UIButton *playButton = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 100, 40)]; 36 | playButton.center = self.view.center; 37 | playButton.backgroundColor = [UIColor purpleColor]; 38 | [playButton setTitle:@"play" forState:UIControlStateNormal]; 39 | [playButton setTitle:@"stop" forState:UIControlStateSelected]; 40 | [playButton addTarget:self action:@selector(handlePlayButtonTapped:) forControlEvents:UIControlEventTouchUpInside]; 41 | [self.view addSubview:playButton]; 42 | 43 | LXMBilayerLabel *bilayerLabel = [[LXMBilayerLabel alloc] initWithFrame:CGRectMake(100, 100, 200, 20)]; 44 | bilayerLabel.center = CGPointMake(CGRectGetWidth([UIScreen mainScreen].bounds) / 2, 200 + 30); 45 | bilayerLabel.backgroundColor = [UIColor lightGrayColor]; 46 | bilayerLabel.textLabel.textColor = [UIColor whiteColor]; 47 | bilayerLabel.font = [UIFont systemFontOfSize:14]; 48 | bilayerLabel.text = @"knocking on heaven's door"; 49 | bilayerLabel.textAlignment = NSTextAlignmentCenter; 50 | [self.view addSubview:bilayerLabel]; 51 | self.bilayerLabel = bilayerLabel; 52 | 53 | } 54 | 55 | - (void)didReceiveMemoryWarning { 56 | [super didReceiveMemoryWarning]; 57 | // Dispose of any resources that can be recreated. 58 | } 59 | 60 | #pragma mark - buttonAction 61 | 62 | - (void)handlePlayButtonTapped:(UIButton *)sender { 63 | NSArray *timeArray = @[ 64 | @(0), 65 | @(3), 66 | @(3.3), 67 | @(3.6), 68 | @(4) 69 | ]; 70 | NSArray *locationArray = @[ 71 | @(0), 72 | @(0.4), 73 | @(0.6), 74 | @(0.8), 75 | @(1) 76 | ]; 77 | 78 | 79 | 80 | sender.selected = !sender.selected; 81 | if (sender.selected) { 82 | [self.bilayerLabel startAnimation]; 83 | [self.lyricsLabel startLyricsAnimationWithTimeArray:timeArray andLocationArray:locationArray]; 84 | } else { 85 | [self.bilayerLabel stopAnimation]; 86 | [self.lyricsLabel stopAnimation]; 87 | } 88 | 89 | } 90 | 91 | @end 92 | -------------------------------------------------------------------------------- /LXMLyricsLabel/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // LXMLyricsLabel 4 | // 5 | // Created by luxiaoming on 15/9/8. 6 | // Copyright (c) 2015年 luxiaoming. 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 | -------------------------------------------------------------------------------- /LXMLyricsLabelTests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | com.ouj.$(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 | -------------------------------------------------------------------------------- /LXMLyricsLabelTests/LXMLyricsLabelTests.m: -------------------------------------------------------------------------------- 1 | // 2 | // LXMLyricsLabelTests.m 3 | // LXMLyricsLabelTests 4 | // 5 | // Created by luxiaoming on 15/9/8. 6 | // Copyright (c) 2015年 luxiaoming. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | 12 | @interface LXMLyricsLabelTests : XCTestCase 13 | 14 | @end 15 | 16 | @implementation LXMLyricsLabelTests 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 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # LXMLyricsLabel 2 | A label that can change its textColor gradually like lyrics 3 | 4 | 5 | it looks like this 6 | ![image](https://raw.githubusercontent.com/Phelthas/LXMLyricsLabel/master/ScreenShots/lxmLyrics2.gif) 7 | 8 | [这里](http://www.cnblogs.com/Phelthas/p/4801889.html)有一篇总结 9 | -------------------------------------------------------------------------------- /ScreenShots/lxmLyrics2.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Phelthas/LXMLyricsLabel/a4eca0758e2d9cb140ac725c9b62f162c717507c/ScreenShots/lxmLyrics2.gif --------------------------------------------------------------------------------