├── README.md ├── TNAnimateSlider.gif ├── TNSliderCustom.xcodeproj ├── project.pbxproj └── project.xcworkspace │ └── contents.xcworkspacedata └── TNSliderCustom ├── AppDelegate.h ├── AppDelegate.m ├── Assets.xcassets └── AppIcon.appiconset │ └── Contents.json ├── Base.lproj ├── LaunchScreen.storyboard └── Main.storyboard ├── Info.plist ├── TNAnimateSlider.h ├── TNAnimateSlider.m ├── ViewController.h ├── ViewController.m ├── main.m └── pikachu ├── 01@2x.png ├── 02@2x.png ├── 03@2x.png └── 04@2x.png /README.md: -------------------------------------------------------------------------------- 1 | # TNAnimateSlider 2 | Custome UISlider with thumb animation 3 | 4 | ## Screenshot 5 | ![](/TNAnimateSlider.gif) 6 | -------------------------------------------------------------------------------- /TNAnimateSlider.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nguyenvantrai2011/TNAnimateSlider/c6113d43247651886ed2a638a98e3bf593ce5821/TNAnimateSlider.gif -------------------------------------------------------------------------------- /TNSliderCustom.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 890449401EDC577800055AD8 /* 01@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 8904493C1EDC577800055AD8 /* 01@2x.png */; }; 11 | 890449411EDC577800055AD8 /* 02@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 8904493D1EDC577800055AD8 /* 02@2x.png */; }; 12 | 890449421EDC577800055AD8 /* 03@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 8904493E1EDC577800055AD8 /* 03@2x.png */; }; 13 | 890449431EDC577800055AD8 /* 04@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 8904493F1EDC577800055AD8 /* 04@2x.png */; }; 14 | 89AB2F7D1DD17D4B00133DA5 /* TNAnimateSlider.m in Sources */ = {isa = PBXBuildFile; fileRef = 89AB2F7C1DD17D4B00133DA5 /* TNAnimateSlider.m */; }; 15 | 89DAEBED1DCC90ED004DEB17 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 89DAEBEC1DCC90ED004DEB17 /* main.m */; }; 16 | 89DAEBF01DCC90EE004DEB17 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 89DAEBEF1DCC90EE004DEB17 /* AppDelegate.m */; }; 17 | 89DAEBF31DCC90EE004DEB17 /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 89DAEBF21DCC90EE004DEB17 /* ViewController.m */; }; 18 | 89DAEBF61DCC90EE004DEB17 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 89DAEBF41DCC90EE004DEB17 /* Main.storyboard */; }; 19 | 89DAEBF81DCC90EE004DEB17 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 89DAEBF71DCC90EE004DEB17 /* Assets.xcassets */; }; 20 | 89DAEBFB1DCC90EE004DEB17 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 89DAEBF91DCC90EE004DEB17 /* LaunchScreen.storyboard */; }; 21 | /* End PBXBuildFile section */ 22 | 23 | /* Begin PBXFileReference section */ 24 | 8904493C1EDC577800055AD8 /* 01@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "01@2x.png"; sourceTree = ""; }; 25 | 8904493D1EDC577800055AD8 /* 02@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "02@2x.png"; sourceTree = ""; }; 26 | 8904493E1EDC577800055AD8 /* 03@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "03@2x.png"; sourceTree = ""; }; 27 | 8904493F1EDC577800055AD8 /* 04@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "04@2x.png"; sourceTree = ""; }; 28 | 89AB2F7B1DD17D4B00133DA5 /* TNAnimateSlider.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TNAnimateSlider.h; sourceTree = ""; }; 29 | 89AB2F7C1DD17D4B00133DA5 /* TNAnimateSlider.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TNAnimateSlider.m; sourceTree = ""; }; 30 | 89DAEBE81DCC90ED004DEB17 /* TNSliderCustom.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = TNSliderCustom.app; sourceTree = BUILT_PRODUCTS_DIR; }; 31 | 89DAEBEC1DCC90ED004DEB17 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 32 | 89DAEBEE1DCC90ED004DEB17 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; 33 | 89DAEBEF1DCC90EE004DEB17 /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; 34 | 89DAEBF11DCC90EE004DEB17 /* ViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = ""; }; 35 | 89DAEBF21DCC90EE004DEB17 /* ViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = ""; }; 36 | 89DAEBF51DCC90EE004DEB17 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 37 | 89DAEBF71DCC90EE004DEB17 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 38 | 89DAEBFA1DCC90EE004DEB17 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 39 | 89DAEBFC1DCC90EE004DEB17 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 40 | /* End PBXFileReference section */ 41 | 42 | /* Begin PBXFrameworksBuildPhase section */ 43 | 89DAEBE51DCC90ED004DEB17 /* Frameworks */ = { 44 | isa = PBXFrameworksBuildPhase; 45 | buildActionMask = 2147483647; 46 | files = ( 47 | ); 48 | runOnlyForDeploymentPostprocessing = 0; 49 | }; 50 | /* End PBXFrameworksBuildPhase section */ 51 | 52 | /* Begin PBXGroup section */ 53 | 8904493B1EDC577800055AD8 /* pikachu */ = { 54 | isa = PBXGroup; 55 | children = ( 56 | 8904493C1EDC577800055AD8 /* 01@2x.png */, 57 | 8904493D1EDC577800055AD8 /* 02@2x.png */, 58 | 8904493E1EDC577800055AD8 /* 03@2x.png */, 59 | 8904493F1EDC577800055AD8 /* 04@2x.png */, 60 | ); 61 | path = pikachu; 62 | sourceTree = ""; 63 | }; 64 | 89DAEBDF1DCC90ED004DEB17 = { 65 | isa = PBXGroup; 66 | children = ( 67 | 89DAEBEA1DCC90ED004DEB17 /* TNSliderCustom */, 68 | 89DAEBE91DCC90ED004DEB17 /* Products */, 69 | ); 70 | sourceTree = ""; 71 | }; 72 | 89DAEBE91DCC90ED004DEB17 /* Products */ = { 73 | isa = PBXGroup; 74 | children = ( 75 | 89DAEBE81DCC90ED004DEB17 /* TNSliderCustom.app */, 76 | ); 77 | name = Products; 78 | sourceTree = ""; 79 | }; 80 | 89DAEBEA1DCC90ED004DEB17 /* TNSliderCustom */ = { 81 | isa = PBXGroup; 82 | children = ( 83 | 8904493B1EDC577800055AD8 /* pikachu */, 84 | 89DAEBEE1DCC90ED004DEB17 /* AppDelegate.h */, 85 | 89DAEBEF1DCC90EE004DEB17 /* AppDelegate.m */, 86 | 89DAEBF11DCC90EE004DEB17 /* ViewController.h */, 87 | 89DAEBF21DCC90EE004DEB17 /* ViewController.m */, 88 | 89AB2F7B1DD17D4B00133DA5 /* TNAnimateSlider.h */, 89 | 89AB2F7C1DD17D4B00133DA5 /* TNAnimateSlider.m */, 90 | 89DAEBF41DCC90EE004DEB17 /* Main.storyboard */, 91 | 89DAEBF71DCC90EE004DEB17 /* Assets.xcassets */, 92 | 89DAEBF91DCC90EE004DEB17 /* LaunchScreen.storyboard */, 93 | 89DAEBFC1DCC90EE004DEB17 /* Info.plist */, 94 | 89DAEBEB1DCC90ED004DEB17 /* Supporting Files */, 95 | ); 96 | path = TNSliderCustom; 97 | sourceTree = ""; 98 | }; 99 | 89DAEBEB1DCC90ED004DEB17 /* Supporting Files */ = { 100 | isa = PBXGroup; 101 | children = ( 102 | 89DAEBEC1DCC90ED004DEB17 /* main.m */, 103 | ); 104 | name = "Supporting Files"; 105 | sourceTree = ""; 106 | }; 107 | /* End PBXGroup section */ 108 | 109 | /* Begin PBXNativeTarget section */ 110 | 89DAEBE71DCC90ED004DEB17 /* TNSliderCustom */ = { 111 | isa = PBXNativeTarget; 112 | buildConfigurationList = 89DAEBFF1DCC90EE004DEB17 /* Build configuration list for PBXNativeTarget "TNSliderCustom" */; 113 | buildPhases = ( 114 | 89DAEBE41DCC90ED004DEB17 /* Sources */, 115 | 89DAEBE51DCC90ED004DEB17 /* Frameworks */, 116 | 89DAEBE61DCC90ED004DEB17 /* Resources */, 117 | ); 118 | buildRules = ( 119 | ); 120 | dependencies = ( 121 | ); 122 | name = TNSliderCustom; 123 | productName = TNSliderCustom; 124 | productReference = 89DAEBE81DCC90ED004DEB17 /* TNSliderCustom.app */; 125 | productType = "com.apple.product-type.application"; 126 | }; 127 | /* End PBXNativeTarget section */ 128 | 129 | /* Begin PBXProject section */ 130 | 89DAEBE01DCC90ED004DEB17 /* Project object */ = { 131 | isa = PBXProject; 132 | attributes = { 133 | LastUpgradeCheck = 0810; 134 | ORGANIZATIONNAME = "Trai Nguyen"; 135 | TargetAttributes = { 136 | 89DAEBE71DCC90ED004DEB17 = { 137 | CreatedOnToolsVersion = 8.0; 138 | DevelopmentTeam = TKKH4YP79W; 139 | ProvisioningStyle = Automatic; 140 | }; 141 | }; 142 | }; 143 | buildConfigurationList = 89DAEBE31DCC90ED004DEB17 /* Build configuration list for PBXProject "TNSliderCustom" */; 144 | compatibilityVersion = "Xcode 3.2"; 145 | developmentRegion = English; 146 | hasScannedForEncodings = 0; 147 | knownRegions = ( 148 | en, 149 | Base, 150 | ); 151 | mainGroup = 89DAEBDF1DCC90ED004DEB17; 152 | productRefGroup = 89DAEBE91DCC90ED004DEB17 /* Products */; 153 | projectDirPath = ""; 154 | projectRoot = ""; 155 | targets = ( 156 | 89DAEBE71DCC90ED004DEB17 /* TNSliderCustom */, 157 | ); 158 | }; 159 | /* End PBXProject section */ 160 | 161 | /* Begin PBXResourcesBuildPhase section */ 162 | 89DAEBE61DCC90ED004DEB17 /* Resources */ = { 163 | isa = PBXResourcesBuildPhase; 164 | buildActionMask = 2147483647; 165 | files = ( 166 | 890449411EDC577800055AD8 /* 02@2x.png in Resources */, 167 | 89DAEBFB1DCC90EE004DEB17 /* LaunchScreen.storyboard in Resources */, 168 | 89DAEBF81DCC90EE004DEB17 /* Assets.xcassets in Resources */, 169 | 890449421EDC577800055AD8 /* 03@2x.png in Resources */, 170 | 89DAEBF61DCC90EE004DEB17 /* Main.storyboard in Resources */, 171 | 890449401EDC577800055AD8 /* 01@2x.png in Resources */, 172 | 890449431EDC577800055AD8 /* 04@2x.png in Resources */, 173 | ); 174 | runOnlyForDeploymentPostprocessing = 0; 175 | }; 176 | /* End PBXResourcesBuildPhase section */ 177 | 178 | /* Begin PBXSourcesBuildPhase section */ 179 | 89DAEBE41DCC90ED004DEB17 /* Sources */ = { 180 | isa = PBXSourcesBuildPhase; 181 | buildActionMask = 2147483647; 182 | files = ( 183 | 89DAEBF31DCC90EE004DEB17 /* ViewController.m in Sources */, 184 | 89DAEBF01DCC90EE004DEB17 /* AppDelegate.m in Sources */, 185 | 89DAEBED1DCC90ED004DEB17 /* main.m in Sources */, 186 | 89AB2F7D1DD17D4B00133DA5 /* TNAnimateSlider.m in Sources */, 187 | ); 188 | runOnlyForDeploymentPostprocessing = 0; 189 | }; 190 | /* End PBXSourcesBuildPhase section */ 191 | 192 | /* Begin PBXVariantGroup section */ 193 | 89DAEBF41DCC90EE004DEB17 /* Main.storyboard */ = { 194 | isa = PBXVariantGroup; 195 | children = ( 196 | 89DAEBF51DCC90EE004DEB17 /* Base */, 197 | ); 198 | name = Main.storyboard; 199 | sourceTree = ""; 200 | }; 201 | 89DAEBF91DCC90EE004DEB17 /* LaunchScreen.storyboard */ = { 202 | isa = PBXVariantGroup; 203 | children = ( 204 | 89DAEBFA1DCC90EE004DEB17 /* Base */, 205 | ); 206 | name = LaunchScreen.storyboard; 207 | sourceTree = ""; 208 | }; 209 | /* End PBXVariantGroup section */ 210 | 211 | /* Begin XCBuildConfiguration section */ 212 | 89DAEBFD1DCC90EE004DEB17 /* Debug */ = { 213 | isa = XCBuildConfiguration; 214 | buildSettings = { 215 | ALWAYS_SEARCH_USER_PATHS = NO; 216 | CLANG_ANALYZER_NONNULL = YES; 217 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 218 | CLANG_CXX_LIBRARY = "libc++"; 219 | CLANG_ENABLE_MODULES = YES; 220 | CLANG_ENABLE_OBJC_ARC = YES; 221 | CLANG_WARN_BOOL_CONVERSION = YES; 222 | CLANG_WARN_CONSTANT_CONVERSION = YES; 223 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 224 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 225 | CLANG_WARN_EMPTY_BODY = YES; 226 | CLANG_WARN_ENUM_CONVERSION = YES; 227 | CLANG_WARN_INFINITE_RECURSION = YES; 228 | CLANG_WARN_INT_CONVERSION = YES; 229 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 230 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 231 | CLANG_WARN_SUSPICIOUS_MOVES = YES; 232 | CLANG_WARN_UNREACHABLE_CODE = YES; 233 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 234 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 235 | COPY_PHASE_STRIP = NO; 236 | DEBUG_INFORMATION_FORMAT = dwarf; 237 | ENABLE_STRICT_OBJC_MSGSEND = YES; 238 | ENABLE_TESTABILITY = YES; 239 | GCC_C_LANGUAGE_STANDARD = gnu99; 240 | GCC_DYNAMIC_NO_PIC = NO; 241 | GCC_NO_COMMON_BLOCKS = YES; 242 | GCC_OPTIMIZATION_LEVEL = 0; 243 | GCC_PREPROCESSOR_DEFINITIONS = ( 244 | "DEBUG=1", 245 | "$(inherited)", 246 | ); 247 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 248 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 249 | GCC_WARN_UNDECLARED_SELECTOR = YES; 250 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 251 | GCC_WARN_UNUSED_FUNCTION = YES; 252 | GCC_WARN_UNUSED_VARIABLE = YES; 253 | IPHONEOS_DEPLOYMENT_TARGET = 10.0; 254 | MTL_ENABLE_DEBUG_INFO = YES; 255 | ONLY_ACTIVE_ARCH = YES; 256 | SDKROOT = iphoneos; 257 | TARGETED_DEVICE_FAMILY = "1,2"; 258 | }; 259 | name = Debug; 260 | }; 261 | 89DAEBFE1DCC90EE004DEB17 /* Release */ = { 262 | isa = XCBuildConfiguration; 263 | buildSettings = { 264 | ALWAYS_SEARCH_USER_PATHS = NO; 265 | CLANG_ANALYZER_NONNULL = YES; 266 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 267 | CLANG_CXX_LIBRARY = "libc++"; 268 | CLANG_ENABLE_MODULES = YES; 269 | CLANG_ENABLE_OBJC_ARC = YES; 270 | CLANG_WARN_BOOL_CONVERSION = YES; 271 | CLANG_WARN_CONSTANT_CONVERSION = YES; 272 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 273 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 274 | CLANG_WARN_EMPTY_BODY = YES; 275 | CLANG_WARN_ENUM_CONVERSION = YES; 276 | CLANG_WARN_INFINITE_RECURSION = YES; 277 | CLANG_WARN_INT_CONVERSION = YES; 278 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 279 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 280 | CLANG_WARN_SUSPICIOUS_MOVES = YES; 281 | CLANG_WARN_UNREACHABLE_CODE = YES; 282 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 283 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 284 | COPY_PHASE_STRIP = NO; 285 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 286 | ENABLE_NS_ASSERTIONS = NO; 287 | ENABLE_STRICT_OBJC_MSGSEND = YES; 288 | GCC_C_LANGUAGE_STANDARD = gnu99; 289 | GCC_NO_COMMON_BLOCKS = YES; 290 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 291 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 292 | GCC_WARN_UNDECLARED_SELECTOR = YES; 293 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 294 | GCC_WARN_UNUSED_FUNCTION = YES; 295 | GCC_WARN_UNUSED_VARIABLE = YES; 296 | IPHONEOS_DEPLOYMENT_TARGET = 10.0; 297 | MTL_ENABLE_DEBUG_INFO = NO; 298 | SDKROOT = iphoneos; 299 | TARGETED_DEVICE_FAMILY = "1,2"; 300 | VALIDATE_PRODUCT = YES; 301 | }; 302 | name = Release; 303 | }; 304 | 89DAEC001DCC90EE004DEB17 /* Debug */ = { 305 | isa = XCBuildConfiguration; 306 | buildSettings = { 307 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 308 | DEVELOPMENT_TEAM = TKKH4YP79W; 309 | INFOPLIST_FILE = TNSliderCustom/Info.plist; 310 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 311 | PRODUCT_BUNDLE_IDENTIFIER = com.trainguyen.TNSliderCustom; 312 | PRODUCT_NAME = "$(TARGET_NAME)"; 313 | }; 314 | name = Debug; 315 | }; 316 | 89DAEC011DCC90EE004DEB17 /* Release */ = { 317 | isa = XCBuildConfiguration; 318 | buildSettings = { 319 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 320 | DEVELOPMENT_TEAM = TKKH4YP79W; 321 | INFOPLIST_FILE = TNSliderCustom/Info.plist; 322 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 323 | PRODUCT_BUNDLE_IDENTIFIER = com.trainguyen.TNSliderCustom; 324 | PRODUCT_NAME = "$(TARGET_NAME)"; 325 | }; 326 | name = Release; 327 | }; 328 | /* End XCBuildConfiguration section */ 329 | 330 | /* Begin XCConfigurationList section */ 331 | 89DAEBE31DCC90ED004DEB17 /* Build configuration list for PBXProject "TNSliderCustom" */ = { 332 | isa = XCConfigurationList; 333 | buildConfigurations = ( 334 | 89DAEBFD1DCC90EE004DEB17 /* Debug */, 335 | 89DAEBFE1DCC90EE004DEB17 /* Release */, 336 | ); 337 | defaultConfigurationIsVisible = 0; 338 | defaultConfigurationName = Release; 339 | }; 340 | 89DAEBFF1DCC90EE004DEB17 /* Build configuration list for PBXNativeTarget "TNSliderCustom" */ = { 341 | isa = XCConfigurationList; 342 | buildConfigurations = ( 343 | 89DAEC001DCC90EE004DEB17 /* Debug */, 344 | 89DAEC011DCC90EE004DEB17 /* Release */, 345 | ); 346 | defaultConfigurationIsVisible = 0; 347 | defaultConfigurationName = Release; 348 | }; 349 | /* End XCConfigurationList section */ 350 | }; 351 | rootObject = 89DAEBE01DCC90ED004DEB17 /* Project object */; 352 | } 353 | -------------------------------------------------------------------------------- /TNSliderCustom.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /TNSliderCustom/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // TNSliderCustom 4 | // 5 | // Created by Trai Nguyen on 11/4/16. 6 | // Copyright © 2016 Trai Nguyen. 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 | -------------------------------------------------------------------------------- /TNSliderCustom/AppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.m 3 | // TNSliderCustom 4 | // 5 | // Created by Trai Nguyen on 11/4/16. 6 | // Copyright © 2016 Trai Nguyen. 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 | 21 | return YES; 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 | -------------------------------------------------------------------------------- /TNSliderCustom/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "20x20", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "20x20", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "29x29", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "29x29", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "40x40", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "40x40", 31 | "scale" : "3x" 32 | }, 33 | { 34 | "idiom" : "iphone", 35 | "size" : "60x60", 36 | "scale" : "2x" 37 | }, 38 | { 39 | "idiom" : "iphone", 40 | "size" : "60x60", 41 | "scale" : "3x" 42 | }, 43 | { 44 | "idiom" : "ipad", 45 | "size" : "20x20", 46 | "scale" : "1x" 47 | }, 48 | { 49 | "idiom" : "ipad", 50 | "size" : "20x20", 51 | "scale" : "2x" 52 | }, 53 | { 54 | "idiom" : "ipad", 55 | "size" : "29x29", 56 | "scale" : "1x" 57 | }, 58 | { 59 | "idiom" : "ipad", 60 | "size" : "29x29", 61 | "scale" : "2x" 62 | }, 63 | { 64 | "idiom" : "ipad", 65 | "size" : "40x40", 66 | "scale" : "1x" 67 | }, 68 | { 69 | "idiom" : "ipad", 70 | "size" : "40x40", 71 | "scale" : "2x" 72 | }, 73 | { 74 | "idiom" : "ipad", 75 | "size" : "76x76", 76 | "scale" : "1x" 77 | }, 78 | { 79 | "idiom" : "ipad", 80 | "size" : "76x76", 81 | "scale" : "2x" 82 | }, 83 | { 84 | "idiom" : "ipad", 85 | "size" : "83.5x83.5", 86 | "scale" : "2x" 87 | } 88 | ], 89 | "info" : { 90 | "version" : 1, 91 | "author" : "xcode" 92 | } 93 | } -------------------------------------------------------------------------------- /TNSliderCustom/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 | -------------------------------------------------------------------------------- /TNSliderCustom/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 | 45 | 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 | -------------------------------------------------------------------------------- /TNSliderCustom/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 | -------------------------------------------------------------------------------- /TNSliderCustom/TNAnimateSlider.h: -------------------------------------------------------------------------------- 1 | // 2 | // TNAnimateSlider.h 3 | // TNAnimateSlider 4 | // 5 | // Created by Trai Nguyen on 11/8/16. 6 | // Copyright © 2016 Trai Nguyen. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | IB_DESIGNABLE 12 | 13 | @interface TNAnimateSlider : UISlider 14 | 15 | @property (strong, nonatomic) IBInspectable NSString *leftValue; 16 | @property (strong, nonatomic) IBInspectable NSString *name; 17 | @property (strong, nonatomic) IBInspectable NSString *thumbImage; 18 | @property (assign, nonatomic) BOOL isAnimated; 19 | 20 | - (void)slideDownWithFinishCompletion:(void (^)())completion; 21 | 22 | @end 23 | -------------------------------------------------------------------------------- /TNSliderCustom/TNAnimateSlider.m: -------------------------------------------------------------------------------- 1 | // 2 | // TNAnimateSlider.m 3 | // TNAnimateSlider 4 | // 5 | // Created by Trai Nguyen on 11/8/16. 6 | // Copyright © 2016 Trai Nguyen. All rights reserved. 7 | // 8 | 9 | #import "TNAnimateSlider.h" 10 | 11 | #define LEFT_VALUE_PADDING 1 12 | 13 | #define NAME_VALUE_PADDING_LEFT 8 14 | 15 | @interface TNAnimateSlider() 16 | 17 | @property (strong, nonatomic) UILabel *lblLeftValue; 18 | 19 | @property (strong, nonatomic) UILabel *lblName; 20 | 21 | @end 22 | 23 | @implementation TNAnimateSlider 24 | 25 | // Only override drawRect: if you perform custom drawing. 26 | // An empty implementation adversely affects performance during animation. 27 | - (void)drawRect:(CGRect)rect { 28 | 29 | CGRect newRect = rect; 30 | newRect.size.height = 39; 31 | 32 | [super drawRect:newRect]; 33 | 34 | self.lblLeftValue = [[UILabel alloc] initWithFrame:CGRectMake(LEFT_VALUE_PADDING, LEFT_VALUE_PADDING, newRect.size.height-2*LEFT_VALUE_PADDING, newRect.size.height-2*LEFT_VALUE_PADDING)]; 35 | [self.lblLeftValue.layer setMasksToBounds:YES]; 36 | [self.lblLeftValue.layer setCornerRadius:(newRect.size.height-2*LEFT_VALUE_PADDING)/2]; 37 | [self.lblLeftValue setBackgroundColor:[UIColor whiteColor]]; 38 | [self.lblLeftValue setTextAlignment:NSTextAlignmentCenter]; 39 | [self.lblLeftValue setText:self.leftValue]; 40 | 41 | [self addSubview:self.lblLeftValue]; 42 | 43 | [self setThumbImage:[UIImage imageNamed:self.thumbImage] forState:UIControlStateNormal]; 44 | 45 | for (id imvSub in self.subviews) { 46 | if ([imvSub isKindOfClass:[UIImageView class]]) { 47 | //UIView>UIImageVIew(maximum track) 1st object in subviews 48 | //UIImageView(minimum track) 2nd object in subviews 49 | //UIImageView(Thumb track) 3rd object in subviews 50 | ((UIImageView *)imvSub).layer.cornerRadius = newRect.size.height/2; 51 | break; 52 | } 53 | } 54 | 55 | self.lblName = [[UILabel alloc] initWithFrame:CGRectZero]; 56 | [self.lblName setText:self.name]; 57 | CGFloat widthIs = [self.lblName.text boundingRectWithSize:self.lblName.frame.size options:NSStringDrawingUsesLineFragmentOrigin attributes:@{ NSFontAttributeName:self.lblName.font} context:nil].size.width; 58 | CGRect lblNameRect = CGRectMake(0, 0, widthIs, newRect.size.height); 59 | self.lblName.frame = lblNameRect; 60 | 61 | [self setValue:self.value animated:YES]; 62 | } 63 | 64 | - (CGRect)trackRectForBounds:(CGRect)bounds { 65 | CGRect newBounds = bounds; 66 | newBounds.size.height = self.frame.size.height; 67 | return newBounds; 68 | } 69 | 70 | - (void)setValue:(float)value animated:(BOOL)animated { 71 | [super setValue:value animated:animated]; 72 | self.isAnimated = YES; 73 | [self.lblName removeFromSuperview]; 74 | for (id subView in self.subviews) { 75 | if ([subView isKindOfClass:[UIImageView class]]) { 76 | NSMutableArray *arrImage = [NSMutableArray new]; 77 | for (int i = 1; i <= 4; i++) { 78 | NSString *strName = [NSString stringWithFormat:@"%.2d.png", i]; 79 | [arrImage addObject:[UIImage imageNamed:strName]]; 80 | } 81 | UIImageView *imvThumb = self.subviews.lastObject; 82 | imvThumb.animationImages = arrImage; 83 | imvThumb.animationDuration = 0.35; 84 | imvThumb.animationRepeatCount = INTMAX_MAX; 85 | [imvThumb startAnimating]; 86 | [self performSelector:@selector(stopAnimation) withObject:nil afterDelay:1.5]; 87 | 88 | UIImage *imgThumb = [UIImage imageNamed:self.thumbImage]; 89 | CGFloat width = ((UIImageView *)subView).frame.size.width; 90 | CGFloat namePaddingLeft = self.lblLeftValue.frame.origin.x + self.lblLeftValue.frame.size.width + NAME_VALUE_PADDING_LEFT; 91 | CGFloat leftDistance = width - imgThumb.size.width/2 - namePaddingLeft; 92 | if (self.lblName.frame.size.width < leftDistance) { 93 | self.lblName.frame = CGRectMake(namePaddingLeft, 0, self.lblName.frame.size.width, self.frame.size.height); 94 | [((UIImageView *)subView) addSubview:self.lblName]; 95 | } 96 | else { 97 | self.lblName.frame = CGRectMake(width + imgThumb.size.width/2 + NAME_VALUE_PADDING_LEFT, 0, self.lblName.frame.size.width, self.frame.size.height); 98 | [self addSubview:self.lblName]; 99 | 100 | } 101 | self.lblName.alpha = 0.0; 102 | CGFloat widthName = self.lblName.frame.size.width; 103 | CGRect rect =self.lblName.frame; 104 | rect.size.width = 0; 105 | self.lblName.frame = rect; 106 | [UIView animateWithDuration:2.25 delay:0.0 usingSpringWithDamping:1.0 initialSpringVelocity:0 options:UIViewAnimationOptionTransitionFlipFromLeft animations:^{ 107 | CGRect rect1 = self.lblName.frame; 108 | rect1.size.width = widthName; 109 | self.lblName.frame = rect1; 110 | self.lblName.alpha = 1.0; 111 | } completion:^(BOOL finished) { 112 | 113 | }]; 114 | break; 115 | } 116 | } 117 | 118 | } 119 | 120 | - (void)stopAnimation { 121 | for (id object in [self.subviews reverseObjectEnumerator]) { 122 | if ([object isKindOfClass:[UIImageView class]]) { 123 | UIImageView *imvThumb = object; 124 | [imvThumb stopAnimating]; 125 | [imvThumb setImage:[UIImage imageNamed:@"01.png"]]; 126 | imvThumb.transform = CGAffineTransformMakeScale(1, 1); 127 | break; 128 | } 129 | } 130 | self.isAnimated = NO; 131 | } 132 | 133 | - (void)slideDownWithFinishCompletion:(void (^)())completion { 134 | if ([self.subviews.lastObject isKindOfClass:[UIImageView class]]) { 135 | [UIView animateWithDuration:0.3 delay:0.0 options:UIViewAnimationOptionCurveEaseIn 136 | animations:^(void) { 137 | UIImageView *imv = self.subviews.lastObject; 138 | imv.transform = CGAffineTransformMakeScale(-1, 1); 139 | } 140 | completion:^(BOOL finished) { 141 | if(finished){ 142 | completion(); 143 | } 144 | }]; 145 | } 146 | } 147 | 148 | @end 149 | -------------------------------------------------------------------------------- /TNSliderCustom/ViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.h 3 | // TNSliderCustom 4 | // 5 | // Created by Trai Nguyen on 11/4/16. 6 | // Copyright © 2016 Trai Nguyen. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface ViewController : UIViewController 12 | 13 | 14 | @end 15 | 16 | -------------------------------------------------------------------------------- /TNSliderCustom/ViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.m 3 | // TNSliderCustom 4 | // 5 | // Created by Trai Nguyen on 11/4/16. 6 | // Copyright © 2016 Trai Nguyen. All rights reserved. 7 | // 8 | 9 | #import "ViewController.h" 10 | #import "TNAnimateSlider.h" 11 | 12 | @interface ViewController () 13 | @property (weak, nonatomic) IBOutlet TNAnimateSlider *sldCustom; 14 | 15 | @end 16 | 17 | @implementation ViewController 18 | 19 | - (void)viewDidLoad { 20 | [super viewDidLoad]; 21 | } 22 | 23 | - (void)viewDidAppear:(BOOL)animated { 24 | [super viewDidAppear:animated]; 25 | } 26 | - (IBAction)onclickRefreshButton:(id)sender { 27 | if (!self.sldCustom.isAnimated && self.sldCustom.value > 1.0) { 28 | [self.sldCustom slideDownWithFinishCompletion:^{ 29 | [UIView animateWithDuration:1.5 animations:^{ 30 | [self.sldCustom setValue:1.0 animated:YES]; 31 | }]; 32 | }]; 33 | } 34 | } 35 | - (IBAction)onclickAnimateButton:(id)sender { 36 | if (!self.sldCustom.isAnimated && self.sldCustom.value < 7.0) { 37 | [UIView animateWithDuration:1.5 animations:^{ 38 | [self.sldCustom setValue:7.0 animated:YES]; 39 | }]; 40 | } 41 | } 42 | 43 | - (void)didReceiveMemoryWarning { 44 | [super didReceiveMemoryWarning]; 45 | // Dispose of any resources that can be recreated. 46 | } 47 | 48 | 49 | @end 50 | -------------------------------------------------------------------------------- /TNSliderCustom/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // TNSliderCustom 4 | // 5 | // Created by Trai Nguyen on 11/4/16. 6 | // Copyright © 2016 Trai Nguyen. 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 | -------------------------------------------------------------------------------- /TNSliderCustom/pikachu/01@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nguyenvantrai2011/TNAnimateSlider/c6113d43247651886ed2a638a98e3bf593ce5821/TNSliderCustom/pikachu/01@2x.png -------------------------------------------------------------------------------- /TNSliderCustom/pikachu/02@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nguyenvantrai2011/TNAnimateSlider/c6113d43247651886ed2a638a98e3bf593ce5821/TNSliderCustom/pikachu/02@2x.png -------------------------------------------------------------------------------- /TNSliderCustom/pikachu/03@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nguyenvantrai2011/TNAnimateSlider/c6113d43247651886ed2a638a98e3bf593ce5821/TNSliderCustom/pikachu/03@2x.png -------------------------------------------------------------------------------- /TNSliderCustom/pikachu/04@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nguyenvantrai2011/TNAnimateSlider/c6113d43247651886ed2a638a98e3bf593ce5821/TNSliderCustom/pikachu/04@2x.png --------------------------------------------------------------------------------