├── LiveLabel.xcodeproj ├── project.pbxproj ├── project.xcworkspace │ ├── contents.xcworkspacedata │ └── xcuserdata │ │ └── apple.xcuserdatad │ │ └── xcdebugger │ │ └── Expressions.xcexplist └── xcuserdata │ └── apple.xcuserdatad │ ├── xcdebugger │ └── Breakpoints_v2.xcbkptlist │ └── xcschemes │ ├── LiveLabel.xcscheme │ └── xcschememanagement.plist ├── LiveLabel ├── AppDelegate.swift ├── Assets.xcassets │ └── AppIcon.appiconset │ │ └── Contents.json ├── Base.lproj │ ├── LaunchScreen.storyboard │ └── Main.storyboard ├── Info.plist ├── LiveLabel │ ├── LiveLabel.swift │ └── LyricLabel.swift └── ViewController.swift ├── README.md ├── animation.gif └── out.gif /LiveLabel.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 180D81F51D17AB6700B477F7 /* LiveLabel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 180D81F41D17AB6700B477F7 /* LiveLabel.swift */; }; 11 | 181BB3B61D17F7720013C422 /* LyricLabel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 181BB3B51D17F7720013C422 /* LyricLabel.swift */; }; 12 | 18C6E7F81D17A53500635DCF /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 18C6E7F71D17A53500635DCF /* AppDelegate.swift */; }; 13 | 18C6E7FA1D17A53500635DCF /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 18C6E7F91D17A53500635DCF /* ViewController.swift */; }; 14 | 18C6E7FD1D17A53500635DCF /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 18C6E7FB1D17A53500635DCF /* Main.storyboard */; }; 15 | 18C6E7FF1D17A53500635DCF /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 18C6E7FE1D17A53500635DCF /* Assets.xcassets */; }; 16 | 18C6E8021D17A53500635DCF /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 18C6E8001D17A53500635DCF /* LaunchScreen.storyboard */; }; 17 | /* End PBXBuildFile section */ 18 | 19 | /* Begin PBXFileReference section */ 20 | 180D81F41D17AB6700B477F7 /* LiveLabel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = LiveLabel.swift; path = LiveLabel/LiveLabel.swift; sourceTree = ""; }; 21 | 181BB3B51D17F7720013C422 /* LyricLabel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = LyricLabel.swift; path = LiveLabel/LyricLabel.swift; sourceTree = ""; }; 22 | 18C6E7F41D17A53500635DCF /* LiveLabel.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = LiveLabel.app; sourceTree = BUILT_PRODUCTS_DIR; }; 23 | 18C6E7F71D17A53500635DCF /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 24 | 18C6E7F91D17A53500635DCF /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; }; 25 | 18C6E7FC1D17A53500635DCF /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 26 | 18C6E7FE1D17A53500635DCF /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 27 | 18C6E8011D17A53500635DCF /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 28 | 18C6E8031D17A53500635DCF /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 29 | /* End PBXFileReference section */ 30 | 31 | /* Begin PBXFrameworksBuildPhase section */ 32 | 18C6E7F11D17A53500635DCF /* Frameworks */ = { 33 | isa = PBXFrameworksBuildPhase; 34 | buildActionMask = 2147483647; 35 | files = ( 36 | ); 37 | runOnlyForDeploymentPostprocessing = 0; 38 | }; 39 | /* End PBXFrameworksBuildPhase section */ 40 | 41 | /* Begin PBXGroup section */ 42 | 180D81F31D17AB4400B477F7 /* LiveLabel */ = { 43 | isa = PBXGroup; 44 | children = ( 45 | 181BB3B51D17F7720013C422 /* LyricLabel.swift */, 46 | 180D81F41D17AB6700B477F7 /* LiveLabel.swift */, 47 | ); 48 | name = LiveLabel; 49 | sourceTree = ""; 50 | }; 51 | 18C6E7EB1D17A53500635DCF = { 52 | isa = PBXGroup; 53 | children = ( 54 | 18C6E7F61D17A53500635DCF /* LiveLabel */, 55 | 18C6E7F51D17A53500635DCF /* Products */, 56 | ); 57 | sourceTree = ""; 58 | }; 59 | 18C6E7F51D17A53500635DCF /* Products */ = { 60 | isa = PBXGroup; 61 | children = ( 62 | 18C6E7F41D17A53500635DCF /* LiveLabel.app */, 63 | ); 64 | name = Products; 65 | sourceTree = ""; 66 | }; 67 | 18C6E7F61D17A53500635DCF /* LiveLabel */ = { 68 | isa = PBXGroup; 69 | children = ( 70 | 180D81F31D17AB4400B477F7 /* LiveLabel */, 71 | 18C6E80C1D17A84C00635DCF /* Resources */, 72 | 18C6E7F71D17A53500635DCF /* AppDelegate.swift */, 73 | 18C6E7F91D17A53500635DCF /* ViewController.swift */, 74 | 18C6E7FB1D17A53500635DCF /* Main.storyboard */, 75 | 18C6E7FE1D17A53500635DCF /* Assets.xcassets */, 76 | 18C6E8001D17A53500635DCF /* LaunchScreen.storyboard */, 77 | 18C6E8031D17A53500635DCF /* Info.plist */, 78 | ); 79 | path = LiveLabel; 80 | sourceTree = ""; 81 | }; 82 | 18C6E80C1D17A84C00635DCF /* Resources */ = { 83 | isa = PBXGroup; 84 | children = ( 85 | ); 86 | path = Resources; 87 | sourceTree = ""; 88 | }; 89 | /* End PBXGroup section */ 90 | 91 | /* Begin PBXNativeTarget section */ 92 | 18C6E7F31D17A53500635DCF /* LiveLabel */ = { 93 | isa = PBXNativeTarget; 94 | buildConfigurationList = 18C6E8061D17A53500635DCF /* Build configuration list for PBXNativeTarget "LiveLabel" */; 95 | buildPhases = ( 96 | 18C6E7F01D17A53500635DCF /* Sources */, 97 | 18C6E7F11D17A53500635DCF /* Frameworks */, 98 | 18C6E7F21D17A53500635DCF /* Resources */, 99 | ); 100 | buildRules = ( 101 | ); 102 | dependencies = ( 103 | ); 104 | name = LiveLabel; 105 | productName = LiveLabel; 106 | productReference = 18C6E7F41D17A53500635DCF /* LiveLabel.app */; 107 | productType = "com.apple.product-type.application"; 108 | }; 109 | /* End PBXNativeTarget section */ 110 | 111 | /* Begin PBXProject section */ 112 | 18C6E7EC1D17A53500635DCF /* Project object */ = { 113 | isa = PBXProject; 114 | attributes = { 115 | LastSwiftUpdateCheck = 0800; 116 | LastUpgradeCheck = 0800; 117 | ORGANIZATIONNAME = HeheData; 118 | TargetAttributes = { 119 | 18C6E7F31D17A53500635DCF = { 120 | CreatedOnToolsVersion = 8.0; 121 | DevelopmentTeam = S6EBGVAJG2; 122 | DevelopmentTeamName = "Cao Jiaxin"; 123 | ProvisioningStyle = Automatic; 124 | }; 125 | }; 126 | }; 127 | buildConfigurationList = 18C6E7EF1D17A53500635DCF /* Build configuration list for PBXProject "LiveLabel" */; 128 | compatibilityVersion = "Xcode 3.2"; 129 | developmentRegion = English; 130 | hasScannedForEncodings = 0; 131 | knownRegions = ( 132 | en, 133 | Base, 134 | ); 135 | mainGroup = 18C6E7EB1D17A53500635DCF; 136 | productRefGroup = 18C6E7F51D17A53500635DCF /* Products */; 137 | projectDirPath = ""; 138 | projectRoot = ""; 139 | targets = ( 140 | 18C6E7F31D17A53500635DCF /* LiveLabel */, 141 | ); 142 | }; 143 | /* End PBXProject section */ 144 | 145 | /* Begin PBXResourcesBuildPhase section */ 146 | 18C6E7F21D17A53500635DCF /* Resources */ = { 147 | isa = PBXResourcesBuildPhase; 148 | buildActionMask = 2147483647; 149 | files = ( 150 | 18C6E8021D17A53500635DCF /* LaunchScreen.storyboard in Resources */, 151 | 18C6E7FF1D17A53500635DCF /* Assets.xcassets in Resources */, 152 | 18C6E7FD1D17A53500635DCF /* Main.storyboard in Resources */, 153 | ); 154 | runOnlyForDeploymentPostprocessing = 0; 155 | }; 156 | /* End PBXResourcesBuildPhase section */ 157 | 158 | /* Begin PBXSourcesBuildPhase section */ 159 | 18C6E7F01D17A53500635DCF /* Sources */ = { 160 | isa = PBXSourcesBuildPhase; 161 | buildActionMask = 2147483647; 162 | files = ( 163 | 18C6E7FA1D17A53500635DCF /* ViewController.swift in Sources */, 164 | 18C6E7F81D17A53500635DCF /* AppDelegate.swift in Sources */, 165 | 180D81F51D17AB6700B477F7 /* LiveLabel.swift in Sources */, 166 | 181BB3B61D17F7720013C422 /* LyricLabel.swift in Sources */, 167 | ); 168 | runOnlyForDeploymentPostprocessing = 0; 169 | }; 170 | /* End PBXSourcesBuildPhase section */ 171 | 172 | /* Begin PBXVariantGroup section */ 173 | 18C6E7FB1D17A53500635DCF /* Main.storyboard */ = { 174 | isa = PBXVariantGroup; 175 | children = ( 176 | 18C6E7FC1D17A53500635DCF /* Base */, 177 | ); 178 | name = Main.storyboard; 179 | sourceTree = ""; 180 | }; 181 | 18C6E8001D17A53500635DCF /* LaunchScreen.storyboard */ = { 182 | isa = PBXVariantGroup; 183 | children = ( 184 | 18C6E8011D17A53500635DCF /* Base */, 185 | ); 186 | name = LaunchScreen.storyboard; 187 | sourceTree = ""; 188 | }; 189 | /* End PBXVariantGroup section */ 190 | 191 | /* Begin XCBuildConfiguration section */ 192 | 18C6E8041D17A53500635DCF /* Debug */ = { 193 | isa = XCBuildConfiguration; 194 | buildSettings = { 195 | ALWAYS_SEARCH_USER_PATHS = NO; 196 | CLANG_ANALYZER_NONNULL = YES; 197 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 198 | CLANG_CXX_LIBRARY = "libc++"; 199 | CLANG_ENABLE_MODULES = YES; 200 | CLANG_ENABLE_OBJC_ARC = YES; 201 | CLANG_WARN_BOOL_CONVERSION = YES; 202 | CLANG_WARN_CONSTANT_CONVERSION = YES; 203 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 204 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 205 | CLANG_WARN_EMPTY_BODY = YES; 206 | CLANG_WARN_ENUM_CONVERSION = YES; 207 | CLANG_WARN_INT_CONVERSION = YES; 208 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 209 | CLANG_WARN_UNREACHABLE_CODE = YES; 210 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 211 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 212 | COPY_PHASE_STRIP = NO; 213 | DEBUG_INFORMATION_FORMAT = dwarf; 214 | ENABLE_STRICT_OBJC_MSGSEND = YES; 215 | ENABLE_TESTABILITY = YES; 216 | GCC_C_LANGUAGE_STANDARD = gnu99; 217 | GCC_DYNAMIC_NO_PIC = NO; 218 | GCC_NO_COMMON_BLOCKS = YES; 219 | GCC_OPTIMIZATION_LEVEL = 0; 220 | GCC_PREPROCESSOR_DEFINITIONS = ( 221 | "DEBUG=1", 222 | "$(inherited)", 223 | ); 224 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 225 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 226 | GCC_WARN_UNDECLARED_SELECTOR = YES; 227 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 228 | GCC_WARN_UNUSED_FUNCTION = YES; 229 | GCC_WARN_UNUSED_VARIABLE = YES; 230 | IPHONEOS_DEPLOYMENT_TARGET = 10.0; 231 | MTL_ENABLE_DEBUG_INFO = YES; 232 | ONLY_ACTIVE_ARCH = YES; 233 | SDKROOT = iphoneos; 234 | SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; 235 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 236 | TARGETED_DEVICE_FAMILY = "1,2"; 237 | }; 238 | name = Debug; 239 | }; 240 | 18C6E8051D17A53500635DCF /* Release */ = { 241 | isa = XCBuildConfiguration; 242 | buildSettings = { 243 | ALWAYS_SEARCH_USER_PATHS = NO; 244 | CLANG_ANALYZER_NONNULL = YES; 245 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 246 | CLANG_CXX_LIBRARY = "libc++"; 247 | CLANG_ENABLE_MODULES = YES; 248 | CLANG_ENABLE_OBJC_ARC = YES; 249 | CLANG_WARN_BOOL_CONVERSION = YES; 250 | CLANG_WARN_CONSTANT_CONVERSION = YES; 251 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 252 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 253 | CLANG_WARN_EMPTY_BODY = YES; 254 | CLANG_WARN_ENUM_CONVERSION = YES; 255 | CLANG_WARN_INT_CONVERSION = YES; 256 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 257 | CLANG_WARN_UNREACHABLE_CODE = YES; 258 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 259 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 260 | COPY_PHASE_STRIP = NO; 261 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 262 | ENABLE_NS_ASSERTIONS = NO; 263 | ENABLE_STRICT_OBJC_MSGSEND = YES; 264 | GCC_C_LANGUAGE_STANDARD = gnu99; 265 | GCC_NO_COMMON_BLOCKS = YES; 266 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 267 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 268 | GCC_WARN_UNDECLARED_SELECTOR = YES; 269 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 270 | GCC_WARN_UNUSED_FUNCTION = YES; 271 | GCC_WARN_UNUSED_VARIABLE = YES; 272 | IPHONEOS_DEPLOYMENT_TARGET = 10.0; 273 | MTL_ENABLE_DEBUG_INFO = NO; 274 | SDKROOT = iphoneos; 275 | SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; 276 | TARGETED_DEVICE_FAMILY = "1,2"; 277 | VALIDATE_PRODUCT = YES; 278 | }; 279 | name = Release; 280 | }; 281 | 18C6E8071D17A53500635DCF /* Debug */ = { 282 | isa = XCBuildConfiguration; 283 | buildSettings = { 284 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 285 | INFOPLIST_FILE = LiveLabel/Info.plist; 286 | IPHONEOS_DEPLOYMENT_TARGET = 9.0; 287 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 288 | PRODUCT_BUNDLE_IDENTIFIER = hehe.LiveLabel; 289 | PRODUCT_NAME = "$(TARGET_NAME)"; 290 | SWIFT_VERSION = 3.0; 291 | }; 292 | name = Debug; 293 | }; 294 | 18C6E8081D17A53500635DCF /* Release */ = { 295 | isa = XCBuildConfiguration; 296 | buildSettings = { 297 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 298 | INFOPLIST_FILE = LiveLabel/Info.plist; 299 | IPHONEOS_DEPLOYMENT_TARGET = 9.0; 300 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 301 | PRODUCT_BUNDLE_IDENTIFIER = hehe.LiveLabel; 302 | PRODUCT_NAME = "$(TARGET_NAME)"; 303 | SWIFT_VERSION = 3.0; 304 | }; 305 | name = Release; 306 | }; 307 | /* End XCBuildConfiguration section */ 308 | 309 | /* Begin XCConfigurationList section */ 310 | 18C6E7EF1D17A53500635DCF /* Build configuration list for PBXProject "LiveLabel" */ = { 311 | isa = XCConfigurationList; 312 | buildConfigurations = ( 313 | 18C6E8041D17A53500635DCF /* Debug */, 314 | 18C6E8051D17A53500635DCF /* Release */, 315 | ); 316 | defaultConfigurationIsVisible = 0; 317 | defaultConfigurationName = Release; 318 | }; 319 | 18C6E8061D17A53500635DCF /* Build configuration list for PBXNativeTarget "LiveLabel" */ = { 320 | isa = XCConfigurationList; 321 | buildConfigurations = ( 322 | 18C6E8071D17A53500635DCF /* Debug */, 323 | 18C6E8081D17A53500635DCF /* Release */, 324 | ); 325 | defaultConfigurationIsVisible = 0; 326 | defaultConfigurationName = Release; 327 | }; 328 | /* End XCConfigurationList section */ 329 | }; 330 | rootObject = 18C6E7EC1D17A53500635DCF /* Project object */; 331 | } 332 | -------------------------------------------------------------------------------- /LiveLabel.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /LiveLabel.xcodeproj/project.xcworkspace/xcuserdata/apple.xcuserdatad/xcdebugger/Expressions.xcexplist: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 7 | 8 | 10 | 11 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /LiveLabel.xcodeproj/xcuserdata/apple.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | -------------------------------------------------------------------------------- /LiveLabel.xcodeproj/xcuserdata/apple.xcuserdatad/xcschemes/LiveLabel.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 39 | 40 | 41 | 42 | 43 | 44 | 54 | 56 | 62 | 63 | 64 | 65 | 66 | 67 | 73 | 75 | 81 | 82 | 83 | 84 | 86 | 87 | 90 | 91 | 92 | -------------------------------------------------------------------------------- /LiveLabel.xcodeproj/xcuserdata/apple.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | LiveLabel.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | SuppressBuildableAutocreation 14 | 15 | 18C6E7F31D17A53500635DCF 16 | 17 | primary 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /LiveLabel/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // LiveLabel 4 | // 5 | // Created by Apple on 16/6/20. 6 | // Copyright © 2016年 HeheData. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | @UIApplicationMain 12 | class AppDelegate: UIResponder, UIApplicationDelegate { 13 | 14 | var window: UIWindow? 15 | 16 | 17 | func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool { 18 | // Override point for customization after application launch. 19 | return true 20 | } 21 | 22 | func applicationWillResignActive(_ application: UIApplication) { 23 | // 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. 24 | // 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. 25 | } 26 | 27 | func applicationDidEnterBackground(_ application: UIApplication) { 28 | // 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. 29 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 30 | } 31 | 32 | func applicationWillEnterForeground(_ application: UIApplication) { 33 | // 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. 34 | } 35 | 36 | func applicationDidBecomeActive(_ application: UIApplication) { 37 | // 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. 38 | } 39 | 40 | func applicationWillTerminate(_ application: UIApplication) { 41 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 42 | } 43 | 44 | 45 | } 46 | 47 | -------------------------------------------------------------------------------- /LiveLabel/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 | } -------------------------------------------------------------------------------- /LiveLabel/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 | -------------------------------------------------------------------------------- /LiveLabel/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 | 26 | 31 | 32 | 37 | 44 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | -------------------------------------------------------------------------------- /LiveLabel/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 | 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 | UISupportedInterfaceOrientations~ipad 40 | 41 | UIInterfaceOrientationPortrait 42 | UIInterfaceOrientationPortraitUpsideDown 43 | UIInterfaceOrientationLandscapeLeft 44 | UIInterfaceOrientationLandscapeRight 45 | 46 | 47 | 48 | -------------------------------------------------------------------------------- /LiveLabel/LiveLabel/LiveLabel.swift: -------------------------------------------------------------------------------- 1 | // 2 | // LiveLabel.swift 3 | // LiveLabel 4 | // 5 | // Created by Apple on 16/6/20. 6 | // Copyright © 2016年 HeheData. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | import Foundation 11 | 12 | extension UIColor { 13 | convenience init(red: Int, green: Int, blue: Int) { 14 | assert(red >= 0 && red <= 255, "Invalid red component") 15 | assert(green >= 0 && green <= 255, "Invalid green component") 16 | assert(blue >= 0 && blue <= 255, "Invalid blue component") 17 | self.init(red: CGFloat(red) / 255.0, green: CGFloat(green) / 255.0, blue: CGFloat(blue) / 255.0, alpha: 1.0) 18 | } 19 | 20 | convenience init(netHex:Int) { 21 | self.init(red:(netHex >> 16) & 0xff, green:(netHex >> 8) & 0xff, blue:netHex & 0xff) 22 | } 23 | } 24 | 25 | class LiveLabel: UILabel { 26 | 27 | private var progress : Int = 0 28 | private var image2Use : UIImage? 29 | 30 | var timer : Timer? 31 | 32 | var fromColor : CGColor = UIColor.init(netHex: 0xC9FFBF).cgColor 33 | var toColor : CGColor = UIColor.init(netHex: 0xFFAFBD).cgColor 34 | 35 | required init?(coder aDecoder: NSCoder) { 36 | super.init(coder: aDecoder) 37 | self.setUp() 38 | } 39 | 40 | override init(frame: CGRect){ 41 | super.init(frame: frame) 42 | self.setUp() 43 | } 44 | 45 | private func setUp(){ 46 | timer = Timer.scheduledTimer(timeInterval: 1.0/100.0, target: self, selector: #selector(update), userInfo: nil, repeats: true); 47 | timer?.fire() 48 | } 49 | 50 | // Update gradient position & redraw the view 51 | @objc private func update(){ 52 | progress += 1 53 | if progress > 66 { 54 | progress = 1 55 | } 56 | self.setNeedsDisplay() 57 | } 58 | 59 | // Get UIImage from CALayer 60 | private func getImageWithCALayer(_ layer:CALayer,_ progress:Int) -> UIImage?{ 61 | UIGraphicsBeginImageContextWithOptions(layer.frame.size, false, 0) 62 | layer.render(in: UIGraphicsGetCurrentContext()!) 63 | let image : UIImage? = UIGraphicsGetImageFromCurrentImageContext() 64 | UIGraphicsEndImageContext() 65 | 66 | return UIImage(cgImage: (image?.cgImage)!.cropping(to: CGRect(x: (image?.size.width)! * CGFloat(progress) * 0.01, y: 0, width: (image?.size.width)! * 1.0/3.0, height: (image?.size.height)!))!) 67 | } 68 | 69 | /** 70 | Control state of animation state, if disabled, the animation stops. 71 | 72 | - parameter enabled: whether enable the animation 73 | */ 74 | func setAnimationEnabled(_ enabled : Bool){ 75 | if enabled && !((timer?.isValid)!) { 76 | timer = Timer.scheduledTimer(timeInterval: 1.0/100.0, target: self, selector: #selector(update), userInfo: nil, repeats: true); 77 | timer?.fire() 78 | } 79 | else{ 80 | timer?.invalidate() 81 | } 82 | } 83 | 84 | override func draw(_ rect: CGRect) { 85 | super.draw(rect) 86 | 87 | let size = self.frame.size 88 | 89 | let gradient: CAGradientLayer = CAGradientLayer() 90 | gradient.frame = CGRect(x: 0, y: 0, width: size.width * 3, height: size.height) 91 | gradient.colors = [fromColor, toColor, fromColor, toColor] 92 | 93 | gradient.endPoint = CGPoint(x: 0, y: 0.5) 94 | gradient.startPoint = CGPoint(x: 0.5, y: 0.5) 95 | getImageWithCALayer(gradient, progress)?.draw(in: CGRect(x: 0, y: 0, width: size.width, height: size.height), blendMode: CGBlendMode.sourceAtop, alpha: 1) 96 | 97 | } 98 | } 99 | -------------------------------------------------------------------------------- /LiveLabel/LiveLabel/LyricLabel.swift: -------------------------------------------------------------------------------- 1 | // 2 | // LyricLabel.swift 3 | // LiveLabel 4 | // 5 | // Created by Apple on 16/6/20. 6 | // Copyright © 2016年 HeheData. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | class LyricLabel: UILabel { 12 | // Set progress to update the view 13 | private var _progress = 1 14 | var progress : Int { 15 | set{ 16 | _progress = newValue 17 | self.setNeedsDisplay() 18 | } 19 | get{ 20 | return _progress 21 | } 22 | } 23 | 24 | // Set Lyric Color & redraw immediately 25 | private var _color : UIColor = UIColor.blue() 26 | var color : UIColor { 27 | get{ 28 | return _color 29 | } 30 | set{ 31 | _color = newValue 32 | self.setNeedsDisplay() 33 | } 34 | } 35 | 36 | private var image2Use : UIImage? 37 | 38 | required init?(coder aDecoder: NSCoder) { 39 | super.init(coder: aDecoder) 40 | } 41 | 42 | override init(frame: CGRect){ 43 | super.init(frame: frame) 44 | } 45 | 46 | override func draw(_ rect: CGRect) { 47 | super.draw(rect) 48 | 49 | let myString: NSString = self.text! as NSString 50 | var size: CGSize = myString.size(attributes: [NSFontAttributeName: UIFont.boldSystemFont(ofSize: self.font.pointSize)]) 51 | size.height = rect.height; 52 | // var size = rect.size; 53 | 54 | // Draw solid color filled image 55 | size.width = max(1, size.width * (CGFloat(progress) * 0.01)) 56 | let image:UIImage = getImageWithColor(color: color, size: size)! 57 | image2Use = image 58 | image2Use?.draw(in: CGRect(x: 0, y: 0, width: size.width, height: size.height), blendMode: CGBlendMode.sourceAtop, alpha: 1) 59 | } 60 | 61 | // Get solid Image with color and size 62 | private func getImageWithColor(color: UIColor, size: CGSize) -> UIImage? { 63 | let rect = CGRect(x: 0, y: 0, width: size.width, height: size.height) 64 | UIGraphicsBeginImageContextWithOptions(size, false, 0) 65 | color.setFill() 66 | UIRectFill(rect) 67 | let image: UIImage = UIGraphicsGetImageFromCurrentImageContext()! 68 | UIGraphicsEndImageContext() 69 | return image 70 | } 71 | 72 | } 73 | -------------------------------------------------------------------------------- /LiveLabel/ViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.swift 3 | // LiveLabel 4 | // 5 | // Created by Apple on 16/6/20. 6 | // Copyright © 2016年 HeheData. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | class ViewController: UIViewController { 12 | @IBOutlet weak var lyricLabel: LyricLabel! 13 | @IBOutlet weak var liveLabel: LiveLabel! 14 | @IBOutlet weak var animateSwitch: UISwitch! 15 | 16 | override func viewDidLoad() { 17 | super.viewDidLoad() 18 | self.setUp() 19 | } 20 | 21 | /** 22 | Do some initialization 23 | */ 24 | func setUp(){ 25 | // LyricLabel Usage 26 | lyricLabel.color = UIColor.blue() 27 | let timer = Timer.scheduledTimer(timeInterval: 1.0/40.0, target: self, selector: #selector(update), userInfo: nil, repeats: true); 28 | timer.fire() 29 | 30 | // LiveLabel Usage 31 | liveLabel.fromColor = UIColor.init(netHex: 0x00C9FF).cgColor 32 | liveLabel.toColor = UIColor.init(netHex: 0x92FE9D).cgColor 33 | 34 | animateSwitch.addTarget(self, action: #selector(controlState), for: UIControlEvents.valueChanged) 35 | } 36 | 37 | /** 38 | Update lyric progress(Only one line support) 39 | */ 40 | func update(){ 41 | lyricLabel.progress += 1 42 | if lyricLabel.progress > 100 { 43 | lyricLabel.progress = 1 44 | } 45 | } 46 | 47 | func controlState(_ sender : UISwitch){ 48 | liveLabel.setAnimationEnabled(sender.isOn) 49 | } 50 | 51 | 52 | } 53 | 54 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # LiveLabel 2 | Gradient glow UILabel and Lyric UILabel for iOS(Build with XCode8.0 beta and written in Swift 3.0) 3 | 4 | ## Overview 5 | UILabel for shimmer and lyric effect 6 | 7 | ## Basic usage 8 | Import LiveLabel.swift and LyricLabel.swift into you project first. 9 | 10 | ![Demo Overview](https://raw.githubusercontent.com/LitleCarl/LiveLabel/master/out.gif) 11 | 12 | ``` swift 13 | // LyricLabel Usage 14 | lyricLabel.color = UIColor.blue() 15 | let timer = Timer.scheduledTimer(timeInterval: 1.0/40.0, target: self, selector: #selector(update), userInfo: nil, repeats: true); 16 | timer.fire() 17 | 18 | // LiveLabel Usage 19 | liveLabel.fromColor = UIColor.init(netHex: 0x00C9FF).cgColor // Here is an entension init method for UIColor from LiveLabel.swift 20 | liveLabel.toColor = UIColor.init(netHex: 0x92FE9D).cgColor // Here is an entension init method for UIColor from LiveLabel.swift 21 | liveLabel.setAnimationEnabled(true) 22 | ... 23 | 24 | /** 25 | Update lyric progress(Only one line support) 26 | */ 27 | func update(){ 28 | lyricLabel.progress += 1 29 | if lyricLabel.progress > 100 { 30 | lyricLabel.progress = 1 31 | } 32 | } 33 | 34 | ``` 35 | ##requirement 36 | XCode 8.0 37 | 38 | ##Installation 39 | Download or clone this repo and import LiveLable.swift & LyricLable.swift and you are ready to go. 40 | 41 | ##TODO 42 | Objective-C implemention 43 | 44 | ##License 45 | MIT 46 | -------------------------------------------------------------------------------- /animation.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jcao-ai/LiveLabel/9bbd6ceb3f92dfc520be3ce2347fadd2bff82967/animation.gif -------------------------------------------------------------------------------- /out.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jcao-ai/LiveLabel/9bbd6ceb3f92dfc520be3ce2347fadd2bff82967/out.gif --------------------------------------------------------------------------------