├── .gitignore ├── JGProgressView Tester ├── Default-568h@2x.png ├── JGProgressView Tester │ ├── Alternative.png │ ├── Alternative@2x.png │ ├── AppDelegate.h │ ├── AppDelegate.m │ ├── Indeterminate.png │ ├── Indeterminate@2x.png │ ├── IndeterminateBar.png │ ├── IndeterminateBar@2x.png │ ├── JGProgressViewTester-Info.plist │ ├── JGProgressViewTester-Prefix.pch │ ├── ViewController.h │ ├── ViewController.m │ ├── en.lproj │ │ ├── InfoPlist.strings │ │ ├── ViewController_iPad.xib │ │ └── ViewController_iPhone.xib │ └── main.m └── JGProgressViewTester.xcodeproj │ ├── project.pbxproj │ └── project.xcworkspace │ └── contents.xcworkspacedata ├── JGProgressView.podspec ├── JGProgressView ├── Indeterminate.png ├── Indeterminate@2x.png ├── IndeterminateBar.png ├── IndeterminateBar@2x.png ├── JGProgressView.h └── JGProgressView.m ├── LICENSE.txt ├── README.md └── Raw.pxm /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | build/ 3 | *.pbxuser 4 | !default.pbxuser 5 | *.mode1v3 6 | !default.mode1v3 7 | *.mode2v3 8 | !default.mode2v3 9 | *.perspectivev3 10 | !default.perspectivev3 11 | *.xcworkspace 12 | !default.xcworkspace 13 | xcuserdata 14 | profile 15 | *.moved-aside 16 | DerivedData 17 | .idea/ -------------------------------------------------------------------------------- /JGProgressView Tester/Default-568h@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JonasGessner/JGProgressView/91470da3a0c1d92b29636448313913b3c446fc10/JGProgressView Tester/Default-568h@2x.png -------------------------------------------------------------------------------- /JGProgressView Tester/JGProgressView Tester/Alternative.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JonasGessner/JGProgressView/91470da3a0c1d92b29636448313913b3c446fc10/JGProgressView Tester/JGProgressView Tester/Alternative.png -------------------------------------------------------------------------------- /JGProgressView Tester/JGProgressView Tester/Alternative@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JonasGessner/JGProgressView/91470da3a0c1d92b29636448313913b3c446fc10/JGProgressView Tester/JGProgressView Tester/Alternative@2x.png -------------------------------------------------------------------------------- /JGProgressView Tester/JGProgressView Tester/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // Image tester 4 | // 5 | // Created by Jonas Gessner on 18.07.12. 6 | // Copyright (c) 2012 Jonas Gessner. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @class ViewController; 12 | 13 | @interface AppDelegate : UIResponder 14 | 15 | @property (strong, nonatomic) UIWindow *window; 16 | 17 | @property (strong, nonatomic) ViewController *viewController; 18 | 19 | @end 20 | -------------------------------------------------------------------------------- /JGProgressView Tester/JGProgressView Tester/AppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.m 3 | // Image tester 4 | // 5 | // Created by Jonas Gessner on 18.07.12. 6 | // Copyright (c) 2012 Jonas Gessner. All rights reserved. 7 | // 8 | 9 | #import "AppDelegate.h" 10 | 11 | #import "ViewController.h" 12 | 13 | @implementation AppDelegate 14 | 15 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 16 | { 17 | self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; 18 | // Override point for customization after application launch. 19 | if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) { 20 | self.viewController = [[ViewController alloc] initWithNibName:@"ViewController_iPhone" bundle:nil]; 21 | } else { 22 | self.viewController = [[ViewController alloc] initWithNibName:@"ViewController_iPad" bundle:nil]; 23 | } 24 | self.window.rootViewController = self.viewController; 25 | [self.window makeKeyAndVisible]; 26 | return YES; 27 | } 28 | 29 | - (void)applicationWillResignActive:(UIApplication *)application 30 | { 31 | // 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. 32 | // 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. 33 | } 34 | 35 | - (void)applicationDidEnterBackground:(UIApplication *)application 36 | { 37 | // 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. 38 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 39 | } 40 | 41 | - (void)applicationWillEnterForeground:(UIApplication *)application 42 | { 43 | // 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. 44 | } 45 | 46 | - (void)applicationDidBecomeActive:(UIApplication *)application 47 | { 48 | // 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. 49 | } 50 | 51 | - (void)applicationWillTerminate:(UIApplication *)application 52 | { 53 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 54 | } 55 | 56 | @end 57 | -------------------------------------------------------------------------------- /JGProgressView Tester/JGProgressView Tester/Indeterminate.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JonasGessner/JGProgressView/91470da3a0c1d92b29636448313913b3c446fc10/JGProgressView Tester/JGProgressView Tester/Indeterminate.png -------------------------------------------------------------------------------- /JGProgressView Tester/JGProgressView Tester/Indeterminate@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JonasGessner/JGProgressView/91470da3a0c1d92b29636448313913b3c446fc10/JGProgressView Tester/JGProgressView Tester/Indeterminate@2x.png -------------------------------------------------------------------------------- /JGProgressView Tester/JGProgressView Tester/IndeterminateBar.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JonasGessner/JGProgressView/91470da3a0c1d92b29636448313913b3c446fc10/JGProgressView Tester/JGProgressView Tester/IndeterminateBar.png -------------------------------------------------------------------------------- /JGProgressView Tester/JGProgressView Tester/IndeterminateBar@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JonasGessner/JGProgressView/91470da3a0c1d92b29636448313913b3c446fc10/JGProgressView Tester/JGProgressView Tester/IndeterminateBar@2x.png -------------------------------------------------------------------------------- /JGProgressView Tester/JGProgressView Tester/JGProgressViewTester-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleDisplayName 8 | ${PRODUCT_NAME} 9 | CFBundleExecutable 10 | ${EXECUTABLE_NAME} 11 | CFBundleIdentifier 12 | de.j-gessner.${PRODUCT_NAME:rfc1034identifier} 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | ${PRODUCT_NAME} 17 | CFBundlePackageType 18 | APPL 19 | CFBundleShortVersionString 20 | 1.0 21 | CFBundleSignature 22 | ???? 23 | CFBundleVersion 24 | 1.0 25 | LSRequiresIPhoneOS 26 | 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 | -------------------------------------------------------------------------------- /JGProgressView Tester/JGProgressView Tester/JGProgressViewTester-Prefix.pch: -------------------------------------------------------------------------------- 1 | // 2 | // Prefix header for all source files of the 'Image tester' target in the 'Image tester' project 3 | // 4 | 5 | #import 6 | 7 | #ifndef __IPHONE_4_0 8 | #warning "This project uses features only available in iOS SDK 4.0 and later." 9 | #endif 10 | 11 | #ifdef __OBJC__ 12 | #import 13 | #import 14 | #endif 15 | -------------------------------------------------------------------------------- /JGProgressView Tester/JGProgressView Tester/ViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.h 3 | // Image tester 4 | // 5 | // Created by Jonas Gessner on 18.07.12. 6 | // Copyright (c) 2012 Jonas Gessner. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface ViewController : UIViewController 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /JGProgressView Tester/JGProgressView Tester/ViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.m 3 | // Image tester 4 | // 5 | // Created by Jonas Gessner on 18.07.12. 6 | // Copyright (c) 2012 Jonas Gessner. All rights reserved. 7 | // 8 | 9 | #import "ViewController.h" 10 | #import "JGProgressView.h" 11 | 12 | @interface ViewController () 13 | 14 | @end 15 | 16 | @implementation ViewController 17 | 18 | 19 | - (void)random:(NSTimer *)timer { 20 | NSUInteger ye = arc4random_uniform(2); 21 | NSUInteger ye2 = arc4random_uniform(50); 22 | BOOL ye3 = arc4random_uniform(2); 23 | BOOL ye4 = arc4random_uniform(2); 24 | 25 | [JGProgressView beginUpdatingSharedProgressViews]; 26 | [JGProgressView setSharedProgressViewStyle:ye]; 27 | [JGProgressView setSharedProgressViewImage:(ye3 ? [UIImage imageNamed:@"Alternative.png"] : nil)]; 28 | [JGProgressView setSharedProgressViewAnimationSpeed:(ye4 ? 1.0f : -1.0f)*(25.0f/(CGFloat)ye2)]; 29 | [JGProgressView endUpdatingSharedProgressViews]; 30 | 31 | } 32 | 33 | - (void)random2:(NSTimer *)timer { 34 | JGProgressView *prog = [timer userInfo][@"OBJ"]; 35 | 36 | NSUInteger ye = arc4random_uniform(2); 37 | BOOL ye2 = arc4random_uniform(300); 38 | BOOL ye3 = arc4random_uniform(2); 39 | NSUInteger width = arc4random_uniform(120)+100; 40 | 41 | BOOL ye4 = arc4random_uniform(2); 42 | 43 | [prog beginUpdates]; 44 | [prog setProgressViewStyle:ye]; 45 | 46 | [prog setAnimationImage:(ye3 ? [UIImage imageNamed:@"Alternative.png"] : nil)]; 47 | [prog setAnimationSpeed:(ye4 ? 1.0f : -1.0f)*(25.0f/(CGFloat)ye2)]; 48 | 49 | CGRect fram = CGRectMake(prog.frame.origin.x, prog.frame.origin.y, width, prog.frame.size.height); 50 | [prog setFrame:fram]; 51 | prog.center = CGPointMake(CGRectGetMidX(self.view.bounds), prog.center.y); 52 | [prog endUpdates]; 53 | } 54 | 55 | - (void)viewDidLoad { 56 | [super viewDidLoad]; 57 | 58 | self.view.backgroundColor = [UIColor whiteColor]; 59 | 60 | //Set up 5 progress views that share their images and transform their properties andomly every 5 seconds (in random:) 61 | NSUInteger count = 5; 62 | NSMutableArray *progressViews = [NSMutableArray arrayWithCapacity:count]; 63 | 64 | NSUInteger i = 0; 65 | 66 | [JGProgressView beginUpdatingSharedProgressViews]; 67 | for (i = 0; i <= count; i++) { 68 | JGProgressView *p = [[JGProgressView alloc] init]; 69 | [p setIndeterminate:YES]; 70 | p.progress = 0.5f; 71 | 72 | p.frame = CGRectMake(50.0f, 40.0f+50.0f*i, 220.0f, p.frame.size.height); 73 | p.center = CGPointMake(CGRectGetMidX(self.view.bounds), p.center.y); 74 | 75 | [self.view addSubview:p]; 76 | [progressViews addObject:p]; 77 | 78 | p.useSharedProperties = YES; 79 | } 80 | 81 | [JGProgressView setSharedProgressViewStyle:UIProgressViewStyleDefault]; 82 | [JGProgressView setSharedProgressViewAnimationSpeed:-2.0]; 83 | 84 | [JGProgressView endUpdatingSharedProgressViews]; 85 | 86 | [NSTimer scheduledTimerWithTimeInterval:5.0 target:self selector:@selector(random:) userInfo:nil repeats:YES]; 87 | 88 | //Set up an individual progress view which doesn't use the shared animation images 89 | JGProgressView *p = [[JGProgressView alloc] initWithProgressViewStyle:UIProgressViewStyleDefault]; 90 | 91 | 92 | [p setAnimationImage:[UIImage imageNamed:@"Alternative.png"]]; 93 | 94 | p.animationSpeed = 1.6; 95 | 96 | [NSTimer scheduledTimerWithTimeInterval:5.0 target:self selector:@selector(random2:) userInfo:@{@"OBJ" : p} repeats:YES]; 97 | 98 | p.frame = CGRectMake(50.0f, 10.0f+50.0f*(i+1), 220.0f, p.frame.size.height); 99 | 100 | [p setIndeterminate:YES]; 101 | 102 | [self.view addSubview:p]; 103 | } 104 | 105 | - (void)didReceiveMemoryWarning 106 | { 107 | [super didReceiveMemoryWarning]; 108 | // Dispose of any resources that can be recreated. 109 | } 110 | 111 | - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation 112 | { 113 | return (interfaceOrientation == UIInterfaceOrientationPortrait); 114 | } 115 | 116 | - (NSUInteger)supportedInterfaceOrientations { 117 | return UIInterfaceOrientationMaskPortrait; 118 | } 119 | 120 | @end 121 | -------------------------------------------------------------------------------- /JGProgressView Tester/JGProgressView Tester/en.lproj/InfoPlist.strings: -------------------------------------------------------------------------------- 1 | /* Localized versions of Info.plist keys */ 2 | 3 | -------------------------------------------------------------------------------- /JGProgressView Tester/JGProgressView Tester/en.lproj/ViewController_iPad.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /JGProgressView Tester/JGProgressView Tester/en.lproj/ViewController_iPhone.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /JGProgressView Tester/JGProgressView Tester/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // Image tester 4 | // 5 | // Created by Jonas Gessner on 18.07.12. 6 | // Copyright (c) 2012 Jonas Gessner. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | #import "AppDelegate.h" 12 | 13 | int main(int argc, char *argv[]) 14 | { 15 | @autoreleasepool { 16 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /JGProgressView Tester/JGProgressViewTester.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | DDACCDE117CB988400FCDDD3 /* Alternative.png in Resources */ = {isa = PBXBuildFile; fileRef = DDACCDDF17CB988400FCDDD3 /* Alternative.png */; }; 11 | DDACCDE217CB988400FCDDD3 /* Alternative@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = DDACCDE017CB988400FCDDD3 /* Alternative@2x.png */; }; 12 | DDD7D0AB171F19600009CBC9 /* Default-568h@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = DDD7D0AA171F19600009CBC9 /* Default-568h@2x.png */; }; 13 | DDD7D0BA171F19920009CBC9 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = DDD7D0AE171F19910009CBC9 /* AppDelegate.m */; }; 14 | DDD7D0BB171F19920009CBC9 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = DDD7D0AF171F19910009CBC9 /* InfoPlist.strings */; }; 15 | DDD7D0BC171F19920009CBC9 /* ViewController_iPad.xib in Resources */ = {isa = PBXBuildFile; fileRef = DDD7D0B1171F19910009CBC9 /* ViewController_iPad.xib */; }; 16 | DDD7D0BD171F19920009CBC9 /* ViewController_iPhone.xib in Resources */ = {isa = PBXBuildFile; fileRef = DDD7D0B3171F19910009CBC9 /* ViewController_iPhone.xib */; }; 17 | DDD7D0BF171F19920009CBC9 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = DDD7D0B7171F19910009CBC9 /* main.m */; }; 18 | DDD7D0C0171F19920009CBC9 /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = DDD7D0B9171F19910009CBC9 /* ViewController.m */; }; 19 | DDD7D0C9171F1AB60009CBC9 /* Indeterminate.png in Resources */ = {isa = PBXBuildFile; fileRef = DDD7D0C5171F1AB60009CBC9 /* Indeterminate.png */; }; 20 | DDD7D0CA171F1AB60009CBC9 /* Indeterminate@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = DDD7D0C6171F1AB60009CBC9 /* Indeterminate@2x.png */; }; 21 | DDD7D0CB171F1AB60009CBC9 /* IndeterminateBar.png in Resources */ = {isa = PBXBuildFile; fileRef = DDD7D0C7171F1AB60009CBC9 /* IndeterminateBar.png */; }; 22 | DDD7D0CC171F1AB60009CBC9 /* IndeterminateBar@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = DDD7D0C8171F1AB60009CBC9 /* IndeterminateBar@2x.png */; }; 23 | DDDA5C5917D296EC00367104 /* JGProgressView.m in Sources */ = {isa = PBXBuildFile; fileRef = DDDA5C5817D296EC00367104 /* JGProgressView.m */; }; 24 | DDEDF84915B6F4F8004F4EB5 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DDEDF84815B6F4F8004F4EB5 /* UIKit.framework */; }; 25 | DDEDF84B15B6F4F8004F4EB5 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DDEDF84A15B6F4F8004F4EB5 /* Foundation.framework */; }; 26 | DDEDF84D15B6F4F8004F4EB5 /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DDEDF84C15B6F4F8004F4EB5 /* CoreGraphics.framework */; }; 27 | KIYDQKWBMRKIEYEVRWSLKUDQ /* QuartzCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = HYXIFWTDXJPPRRMDCEPMDTJH /* QuartzCore.framework */; }; 28 | /* End PBXBuildFile section */ 29 | 30 | /* Begin PBXFileReference section */ 31 | DDACCDDF17CB988400FCDDD3 /* Alternative.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = Alternative.png; sourceTree = ""; }; 32 | DDACCDE017CB988400FCDDD3 /* Alternative@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Alternative@2x.png"; sourceTree = ""; }; 33 | DDD7D0AA171F19600009CBC9 /* Default-568h@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "Default-568h@2x.png"; path = "../Default-568h@2x.png"; sourceTree = ""; }; 34 | DDD7D0AD171F19910009CBC9 /* AppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; 35 | DDD7D0AE171F19910009CBC9 /* AppDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; 36 | DDD7D0B0171F19910009CBC9 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = ""; }; 37 | DDD7D0B2171F19910009CBC9 /* en */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = en; path = en.lproj/ViewController_iPad.xib; sourceTree = ""; }; 38 | DDD7D0B4171F19910009CBC9 /* en */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = en; path = en.lproj/ViewController_iPhone.xib; sourceTree = ""; }; 39 | DDD7D0B5171F19910009CBC9 /* JGProgressViewTester-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "JGProgressViewTester-Info.plist"; sourceTree = ""; }; 40 | DDD7D0B6171F19910009CBC9 /* JGProgressViewTester-Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "JGProgressViewTester-Prefix.pch"; sourceTree = ""; }; 41 | DDD7D0B7171F19910009CBC9 /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 42 | DDD7D0B8171F19910009CBC9 /* ViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = ""; }; 43 | DDD7D0B9171F19910009CBC9 /* ViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = ""; }; 44 | DDD7D0C5171F1AB60009CBC9 /* Indeterminate.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = Indeterminate.png; sourceTree = ""; }; 45 | DDD7D0C6171F1AB60009CBC9 /* Indeterminate@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Indeterminate@2x.png"; sourceTree = ""; }; 46 | DDD7D0C7171F1AB60009CBC9 /* IndeterminateBar.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = IndeterminateBar.png; sourceTree = ""; }; 47 | DDD7D0C8171F1AB60009CBC9 /* IndeterminateBar@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "IndeterminateBar@2x.png"; sourceTree = ""; }; 48 | DDDA5C5717D296EC00367104 /* JGProgressView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = JGProgressView.h; path = ../../JGProgressView/JGProgressView.h; sourceTree = ""; }; 49 | DDDA5C5817D296EC00367104 /* JGProgressView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = JGProgressView.m; path = ../../JGProgressView/JGProgressView.m; sourceTree = ""; }; 50 | DDEDF84415B6F4F8004F4EB5 /* JGProgressViewTester.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = JGProgressViewTester.app; sourceTree = BUILT_PRODUCTS_DIR; }; 51 | DDEDF84815B6F4F8004F4EB5 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; }; 52 | DDEDF84A15B6F4F8004F4EB5 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; 53 | DDEDF84C15B6F4F8004F4EB5 /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; }; 54 | HYXIFWTDXJPPRRMDCEPMDTJH /* QuartzCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = QuartzCore.framework; path = System/Library/Frameworks/QuartzCore.framework; sourceTree = SDKROOT; }; 55 | /* End PBXFileReference section */ 56 | 57 | /* Begin PBXFrameworksBuildPhase section */ 58 | DDEDF84115B6F4F8004F4EB5 /* Frameworks */ = { 59 | isa = PBXFrameworksBuildPhase; 60 | buildActionMask = 2147483647; 61 | files = ( 62 | DDEDF84915B6F4F8004F4EB5 /* UIKit.framework in Frameworks */, 63 | DDEDF84B15B6F4F8004F4EB5 /* Foundation.framework in Frameworks */, 64 | DDEDF84D15B6F4F8004F4EB5 /* CoreGraphics.framework in Frameworks */, 65 | KIYDQKWBMRKIEYEVRWSLKUDQ /* QuartzCore.framework in Frameworks */, 66 | ); 67 | runOnlyForDeploymentPostprocessing = 0; 68 | }; 69 | /* End PBXFrameworksBuildPhase section */ 70 | 71 | /* Begin PBXGroup section */ 72 | DDD7D0AC171F19910009CBC9 /* JGProgressView Tester */ = { 73 | isa = PBXGroup; 74 | children = ( 75 | DDDA5C5717D296EC00367104 /* JGProgressView.h */, 76 | DDDA5C5817D296EC00367104 /* JGProgressView.m */, 77 | DDD7D0AD171F19910009CBC9 /* AppDelegate.h */, 78 | DDD7D0AE171F19910009CBC9 /* AppDelegate.m */, 79 | DDD7D0B8171F19910009CBC9 /* ViewController.h */, 80 | DDD7D0B9171F19910009CBC9 /* ViewController.m */, 81 | DDACCDDF17CB988400FCDDD3 /* Alternative.png */, 82 | DDACCDE017CB988400FCDDD3 /* Alternative@2x.png */, 83 | DDD7D0C5171F1AB60009CBC9 /* Indeterminate.png */, 84 | DDD7D0C6171F1AB60009CBC9 /* Indeterminate@2x.png */, 85 | DDD7D0C7171F1AB60009CBC9 /* IndeterminateBar.png */, 86 | DDD7D0C8171F1AB60009CBC9 /* IndeterminateBar@2x.png */, 87 | DDD7D0B1171F19910009CBC9 /* ViewController_iPad.xib */, 88 | DDD7D0B3171F19910009CBC9 /* ViewController_iPhone.xib */, 89 | DDD7D0C1171F19A10009CBC9 /* Other */, 90 | ); 91 | path = "JGProgressView Tester"; 92 | sourceTree = ""; 93 | }; 94 | DDD7D0C1171F19A10009CBC9 /* Other */ = { 95 | isa = PBXGroup; 96 | children = ( 97 | DDD7D0AA171F19600009CBC9 /* Default-568h@2x.png */, 98 | DDD7D0AF171F19910009CBC9 /* InfoPlist.strings */, 99 | DDD7D0B5171F19910009CBC9 /* JGProgressViewTester-Info.plist */, 100 | DDD7D0B6171F19910009CBC9 /* JGProgressViewTester-Prefix.pch */, 101 | DDD7D0B7171F19910009CBC9 /* main.m */, 102 | ); 103 | name = Other; 104 | sourceTree = ""; 105 | }; 106 | DDEDF83915B6F4F8004F4EB5 = { 107 | isa = PBXGroup; 108 | children = ( 109 | DDD7D0AC171F19910009CBC9 /* JGProgressView Tester */, 110 | DDEDF84715B6F4F8004F4EB5 /* Frameworks */, 111 | DDEDF84515B6F4F8004F4EB5 /* Products */, 112 | ); 113 | sourceTree = ""; 114 | }; 115 | DDEDF84515B6F4F8004F4EB5 /* Products */ = { 116 | isa = PBXGroup; 117 | children = ( 118 | DDEDF84415B6F4F8004F4EB5 /* JGProgressViewTester.app */, 119 | ); 120 | name = Products; 121 | sourceTree = ""; 122 | }; 123 | DDEDF84715B6F4F8004F4EB5 /* Frameworks */ = { 124 | isa = PBXGroup; 125 | children = ( 126 | DDEDF84815B6F4F8004F4EB5 /* UIKit.framework */, 127 | DDEDF84A15B6F4F8004F4EB5 /* Foundation.framework */, 128 | DDEDF84C15B6F4F8004F4EB5 /* CoreGraphics.framework */, 129 | HYXIFWTDXJPPRRMDCEPMDTJH /* QuartzCore.framework */, 130 | ); 131 | name = Frameworks; 132 | sourceTree = ""; 133 | }; 134 | /* End PBXGroup section */ 135 | 136 | /* Begin PBXNativeTarget section */ 137 | DDEDF84315B6F4F8004F4EB5 /* JGProgressViewTester */ = { 138 | isa = PBXNativeTarget; 139 | buildConfigurationList = DDEDF86515B6F4F8004F4EB5 /* Build configuration list for PBXNativeTarget "JGProgressViewTester" */; 140 | buildPhases = ( 141 | DDEDF84015B6F4F8004F4EB5 /* Sources */, 142 | DDEDF84115B6F4F8004F4EB5 /* Frameworks */, 143 | DDEDF84215B6F4F8004F4EB5 /* Resources */, 144 | ); 145 | buildRules = ( 146 | ); 147 | dependencies = ( 148 | ); 149 | name = JGProgressViewTester; 150 | productName = "Image tester"; 151 | productReference = DDEDF84415B6F4F8004F4EB5 /* JGProgressViewTester.app */; 152 | productType = "com.apple.product-type.application"; 153 | }; 154 | /* End PBXNativeTarget section */ 155 | 156 | /* Begin PBXProject section */ 157 | DDEDF83B15B6F4F8004F4EB5 /* Project object */ = { 158 | isa = PBXProject; 159 | attributes = { 160 | LastUpgradeCheck = 0510; 161 | ORGANIZATIONNAME = "Jonas Gessner"; 162 | }; 163 | buildConfigurationList = DDEDF83E15B6F4F8004F4EB5 /* Build configuration list for PBXProject "JGProgressViewTester" */; 164 | compatibilityVersion = "Xcode 3.2"; 165 | developmentRegion = English; 166 | hasScannedForEncodings = 0; 167 | knownRegions = ( 168 | en, 169 | ); 170 | mainGroup = DDEDF83915B6F4F8004F4EB5; 171 | productRefGroup = DDEDF84515B6F4F8004F4EB5 /* Products */; 172 | projectDirPath = ""; 173 | projectRoot = ""; 174 | targets = ( 175 | DDEDF84315B6F4F8004F4EB5 /* JGProgressViewTester */, 176 | ); 177 | }; 178 | /* End PBXProject section */ 179 | 180 | /* Begin PBXResourcesBuildPhase section */ 181 | DDEDF84215B6F4F8004F4EB5 /* Resources */ = { 182 | isa = PBXResourcesBuildPhase; 183 | buildActionMask = 2147483647; 184 | files = ( 185 | DDD7D0AB171F19600009CBC9 /* Default-568h@2x.png in Resources */, 186 | DDD7D0BB171F19920009CBC9 /* InfoPlist.strings in Resources */, 187 | DDD7D0BC171F19920009CBC9 /* ViewController_iPad.xib in Resources */, 188 | DDD7D0BD171F19920009CBC9 /* ViewController_iPhone.xib in Resources */, 189 | DDD7D0C9171F1AB60009CBC9 /* Indeterminate.png in Resources */, 190 | DDD7D0CA171F1AB60009CBC9 /* Indeterminate@2x.png in Resources */, 191 | DDACCDE217CB988400FCDDD3 /* Alternative@2x.png in Resources */, 192 | DDD7D0CB171F1AB60009CBC9 /* IndeterminateBar.png in Resources */, 193 | DDD7D0CC171F1AB60009CBC9 /* IndeterminateBar@2x.png in Resources */, 194 | DDACCDE117CB988400FCDDD3 /* Alternative.png in Resources */, 195 | ); 196 | runOnlyForDeploymentPostprocessing = 0; 197 | }; 198 | /* End PBXResourcesBuildPhase section */ 199 | 200 | /* Begin PBXSourcesBuildPhase section */ 201 | DDEDF84015B6F4F8004F4EB5 /* Sources */ = { 202 | isa = PBXSourcesBuildPhase; 203 | buildActionMask = 2147483647; 204 | files = ( 205 | DDDA5C5917D296EC00367104 /* JGProgressView.m in Sources */, 206 | DDD7D0BA171F19920009CBC9 /* AppDelegate.m in Sources */, 207 | DDD7D0BF171F19920009CBC9 /* main.m in Sources */, 208 | DDD7D0C0171F19920009CBC9 /* ViewController.m in Sources */, 209 | ); 210 | runOnlyForDeploymentPostprocessing = 0; 211 | }; 212 | /* End PBXSourcesBuildPhase section */ 213 | 214 | /* Begin PBXVariantGroup section */ 215 | DDD7D0AF171F19910009CBC9 /* InfoPlist.strings */ = { 216 | isa = PBXVariantGroup; 217 | children = ( 218 | DDD7D0B0171F19910009CBC9 /* en */, 219 | ); 220 | name = InfoPlist.strings; 221 | sourceTree = ""; 222 | }; 223 | DDD7D0B1171F19910009CBC9 /* ViewController_iPad.xib */ = { 224 | isa = PBXVariantGroup; 225 | children = ( 226 | DDD7D0B2171F19910009CBC9 /* en */, 227 | ); 228 | name = ViewController_iPad.xib; 229 | sourceTree = ""; 230 | }; 231 | DDD7D0B3171F19910009CBC9 /* ViewController_iPhone.xib */ = { 232 | isa = PBXVariantGroup; 233 | children = ( 234 | DDD7D0B4171F19910009CBC9 /* en */, 235 | ); 236 | name = ViewController_iPhone.xib; 237 | sourceTree = ""; 238 | }; 239 | /* End PBXVariantGroup section */ 240 | 241 | /* Begin XCBuildConfiguration section */ 242 | DDEDF86315B6F4F8004F4EB5 /* Debug */ = { 243 | isa = XCBuildConfiguration; 244 | buildSettings = { 245 | ALWAYS_SEARCH_USER_PATHS = NO; 246 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 247 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 248 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 249 | COPY_PHASE_STRIP = NO; 250 | FRAMEWORK_SEARCH_PATHS = "\"/Applications/Spark Inspector.app/Contents/Resources/Frameworks\""; 251 | GCC_C_LANGUAGE_STANDARD = gnu99; 252 | GCC_DYNAMIC_NO_PIC = NO; 253 | GCC_OPTIMIZATION_LEVEL = 0; 254 | GCC_PREPROCESSOR_DEFINITIONS = ( 255 | "DEBUG=1", 256 | "$(inherited)", 257 | ); 258 | GCC_SYMBOLS_PRIVATE_EXTERN = NO; 259 | GCC_WARN_ABOUT_RETURN_TYPE = YES; 260 | GCC_WARN_UNINITIALIZED_AUTOS = YES; 261 | GCC_WARN_UNUSED_VARIABLE = YES; 262 | IPHONEOS_DEPLOYMENT_TARGET = 5.1.1; 263 | ONLY_ACTIVE_ARCH = YES; 264 | OTHER_LDFLAGS = ( 265 | "-ObjC", 266 | "-framework", 267 | SparkInspector, 268 | ); 269 | SDKROOT = iphoneos; 270 | TARGETED_DEVICE_FAMILY = "1,2"; 271 | }; 272 | name = Debug; 273 | }; 274 | DDEDF86415B6F4F8004F4EB5 /* Release */ = { 275 | isa = XCBuildConfiguration; 276 | buildSettings = { 277 | ALWAYS_SEARCH_USER_PATHS = NO; 278 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 279 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 280 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 281 | COPY_PHASE_STRIP = YES; 282 | GCC_C_LANGUAGE_STANDARD = gnu99; 283 | GCC_WARN_ABOUT_RETURN_TYPE = YES; 284 | GCC_WARN_UNINITIALIZED_AUTOS = YES; 285 | GCC_WARN_UNUSED_VARIABLE = YES; 286 | IPHONEOS_DEPLOYMENT_TARGET = 5.1.1; 287 | OTHER_CFLAGS = "-DNS_BLOCK_ASSERTIONS=1"; 288 | SDKROOT = iphoneos; 289 | TARGETED_DEVICE_FAMILY = "1,2"; 290 | VALIDATE_PRODUCT = YES; 291 | }; 292 | name = Release; 293 | }; 294 | DDEDF86615B6F4F8004F4EB5 /* Debug */ = { 295 | isa = XCBuildConfiguration; 296 | buildSettings = { 297 | CLANG_ENABLE_OBJC_ARC = YES; 298 | FRAMEWORK_SEARCH_PATHS = ""; 299 | GCC_PRECOMPILE_PREFIX_HEADER = YES; 300 | GCC_PREFIX_HEADER = "JGProgressView Tester/JGProgressViewTester-Prefix.pch"; 301 | INFOPLIST_FILE = "$(SRCROOT)/JGProgressView Tester/JGProgressViewTester-Info.plist"; 302 | IPHONEOS_DEPLOYMENT_TARGET = 5.1.1; 303 | OTHER_LDFLAGS = ""; 304 | PRODUCT_NAME = JGProgressViewTester; 305 | WRAPPER_EXTENSION = app; 306 | }; 307 | name = Debug; 308 | }; 309 | DDEDF86715B6F4F8004F4EB5 /* Release */ = { 310 | isa = XCBuildConfiguration; 311 | buildSettings = { 312 | CLANG_ENABLE_OBJC_ARC = YES; 313 | GCC_PRECOMPILE_PREFIX_HEADER = YES; 314 | GCC_PREFIX_HEADER = "JGProgressView Tester/JGProgressViewTester-Prefix.pch"; 315 | INFOPLIST_FILE = "$(SRCROOT)/JGProgressView Tester/JGProgressViewTester-Info.plist"; 316 | IPHONEOS_DEPLOYMENT_TARGET = 5.1.1; 317 | PRODUCT_NAME = JGProgressViewTester; 318 | WRAPPER_EXTENSION = app; 319 | }; 320 | name = Release; 321 | }; 322 | /* End XCBuildConfiguration section */ 323 | 324 | /* Begin XCConfigurationList section */ 325 | DDEDF83E15B6F4F8004F4EB5 /* Build configuration list for PBXProject "JGProgressViewTester" */ = { 326 | isa = XCConfigurationList; 327 | buildConfigurations = ( 328 | DDEDF86315B6F4F8004F4EB5 /* Debug */, 329 | DDEDF86415B6F4F8004F4EB5 /* Release */, 330 | ); 331 | defaultConfigurationIsVisible = 0; 332 | defaultConfigurationName = Release; 333 | }; 334 | DDEDF86515B6F4F8004F4EB5 /* Build configuration list for PBXNativeTarget "JGProgressViewTester" */ = { 335 | isa = XCConfigurationList; 336 | buildConfigurations = ( 337 | DDEDF86615B6F4F8004F4EB5 /* Debug */, 338 | DDEDF86715B6F4F8004F4EB5 /* Release */, 339 | ); 340 | defaultConfigurationIsVisible = 0; 341 | defaultConfigurationName = Release; 342 | }; 343 | /* End XCConfigurationList section */ 344 | }; 345 | rootObject = DDEDF83B15B6F4F8004F4EB5 /* Project object */; 346 | } 347 | -------------------------------------------------------------------------------- /JGProgressView Tester/JGProgressViewTester.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /JGProgressView.podspec: -------------------------------------------------------------------------------- 1 | Pod::Spec.new do |s| 2 | 3 | s.name = "JGProgressView" 4 | s.version = "1.2.1" 5 | s.summary = "UIProgressView subclass with an animated 'Indeterminate' setting." 6 | s.description = <<-DESC 7 | UIProgressView subclass with an animated "Indeterminate" setting. 8 | DESC 9 | s.homepage = "https://github.com/JonasGessner/JGProgressView" 10 | s.license = { :type => "MIT", :file => "LICENSE.txt" } 11 | s.author = "Jonas Gessner" 12 | s.social_media_url = "http://twitter.com/JonasGessner" 13 | s.platform = :ios, "5.0" 14 | s.source = { :git => "https://github.com/JonasGessner/JGProgressView.git", :tag => "v1.2.1" } 15 | s.source_files = "JGProgressView/*.{h,m}" 16 | s.resources = "JGProgressView/*.png" 17 | s.frameworks = "Foundation", "UIKit", "QuartzCore" 18 | s.requires_arc = true 19 | 20 | end 21 | -------------------------------------------------------------------------------- /JGProgressView/Indeterminate.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JonasGessner/JGProgressView/91470da3a0c1d92b29636448313913b3c446fc10/JGProgressView/Indeterminate.png -------------------------------------------------------------------------------- /JGProgressView/Indeterminate@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JonasGessner/JGProgressView/91470da3a0c1d92b29636448313913b3c446fc10/JGProgressView/Indeterminate@2x.png -------------------------------------------------------------------------------- /JGProgressView/IndeterminateBar.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JonasGessner/JGProgressView/91470da3a0c1d92b29636448313913b3c446fc10/JGProgressView/IndeterminateBar.png -------------------------------------------------------------------------------- /JGProgressView/IndeterminateBar@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JonasGessner/JGProgressView/91470da3a0c1d92b29636448313913b3c446fc10/JGProgressView/IndeterminateBar@2x.png -------------------------------------------------------------------------------- /JGProgressView/JGProgressView.h: -------------------------------------------------------------------------------- 1 | // 2 | // JGProgressView.h 3 | // 4 | // Created by Jonas Gessner on 20.07.12. 5 | // Copyright (c) 2012 Jonas Gessner. All rights reserved. 6 | // 7 | 8 | #import 9 | 10 | @interface JGProgressView : UIProgressView 11 | 12 | 13 | /** 14 | Defaults to \c NO. Set to \c YES to use shared image, animation speed and progress view style. This may help increasing performance when using many progress views with the same properties (ex. in a UITableViewCell). 15 | */ 16 | @property (nonatomic, assign) BOOL useSharedProperties; 17 | 18 | 19 | 20 | 21 | 22 | /** 23 | Property for the indeterminate setting, default is NO, set to YES to start the indeterminate animation. 24 | */ 25 | @property (nonatomic, assign, getter = isIndeterminate) BOOL indeterminate; 26 | 27 | 28 | 29 | 30 | 31 | 32 | /** 33 | Defaults to 0.5, negative values will reverse the direction of the animation. 34 | */ 35 | @property (nonatomic, assign) NSTimeInterval animationSpeed; 36 | 37 | + (void)setSharedProgressViewAnimationSpeed:(NSTimeInterval)speed; 38 | 39 | 40 | 41 | 42 | 43 | /** 44 | Use this property to set a custom image to use for the indeterminate animation. Set to \c nil to use the standard image for the current UIProgressViewStyle 45 | */ 46 | @property (nonatomic, strong) UIImage *animationImage; 47 | 48 | + (void)setSharedProgressViewImage:(UIImage *)img; 49 | 50 | 51 | 52 | /** 53 | Set the \c UIProgressViewStyle of all progress views that use shared images. 54 | */ 55 | + (void)setSharedProgressViewStyle:(UIProgressViewStyle)style; 56 | 57 | 58 | 59 | 60 | //--------------------------------------------- 61 | //Use begin- and endUpdates to increase performance when changing multiple properties of JGProgressView 62 | //---------------------------------------------- 63 | 64 | 65 | - (void)beginUpdates; 66 | + (void)beginUpdatingSharedProgressViews; 67 | 68 | 69 | 70 | - (void)endUpdates; 71 | + (void)endUpdatingSharedProgressViews; 72 | 73 | @end 74 | -------------------------------------------------------------------------------- /JGProgressView/JGProgressView.m: -------------------------------------------------------------------------------- 1 | // 2 | // JGProgressView.m 3 | // 4 | // Created by Jonas Gessner on 20.07.12. 5 | // Copyright (c) 2012 Jonas Gessner. All rights reserved. 6 | // 7 | 8 | #import "JGProgressView.h" 9 | #import 10 | 11 | static NSMutableSet *_sharedProgressViews; 12 | 13 | static UIImage *_sharedImage; 14 | static UIProgressViewStyle _sharedStyle = UIProgressViewStyleDefault; 15 | static NSTimeInterval _sharedAnimationSpeed = 0.5; 16 | static BOOL _sharedAnimateToRight = NO; 17 | static BOOL _updatingShared = NO; 18 | 19 | static NSMutableArray *_sharedAnimationImages; 20 | 21 | 22 | #if !__has_feature(objc_arc) 23 | #warning JGProgressView requires ARC. 24 | #endif 25 | 26 | 27 | #ifndef kCFCoreFoundationVersionNumber_iOS_7_0 28 | #define kCFCoreFoundationVersionNumber_iOS_7_0 847.2 29 | #endif 30 | 31 | #define iOS7 (kCFCoreFoundationVersionNumber >= kCFCoreFoundationVersionNumber_iOS_7_0) 32 | 33 | @interface JGWeakReference : NSObject 34 | 35 | @property (nonatomic, weak) id object; 36 | 37 | @end 38 | 39 | @implementation JGWeakReference 40 | 41 | @end 42 | 43 | 44 | @interface UIImage (JGAddons) 45 | 46 | - (UIImage *)attachImage:(UIImage *)image; 47 | - (UIImage *)cropByX:(CGFloat)x; 48 | 49 | @end 50 | 51 | @implementation UIImage (JGAddons) 52 | 53 | - (UIImage *)cropByX:(CGFloat)x { 54 | UIGraphicsBeginImageContextWithOptions(CGSizeMake(self.size.width-x, self.size.height), NO, 0.0f); 55 | CGContextRef context = UIGraphicsGetCurrentContext(); 56 | 57 | CGContextTranslateCTM(context, 0.0f, self.size.height); 58 | CGContextScaleCTM(context, 1.0f, -1.0f); 59 | 60 | CGContextDrawImage(context, CGRectMake(0.0f, 0.0f, self.size.width, self.size.height), self.CGImage); 61 | 62 | CGImageRef image = CGBitmapContextCreateImage(context); 63 | 64 | UIImage *result = [UIImage imageWithCGImage:image scale:self.scale orientation:UIImageOrientationUp]; 65 | 66 | CGImageRelease(image); 67 | 68 | UIGraphicsEndImageContext(); 69 | 70 | return result; 71 | } 72 | 73 | - (UIImage *)attachImage:(UIImage *)image { 74 | UIGraphicsBeginImageContextWithOptions(CGSizeMake(self.size.width+image.size.width, self.size.height), NO, 0.0f); 75 | CGContextRef context = UIGraphicsGetCurrentContext(); 76 | 77 | CGContextTranslateCTM(context, 0.0f, self.size.height); 78 | CGContextScaleCTM(context, 1.0f, -1.0f); 79 | 80 | CGContextDrawImage(context, CGRectMake(0.0f, 0.0f, self.size.width, self.size.height), self.CGImage); 81 | 82 | CGContextDrawImage(context, CGRectMake(self.size.width, 0.0f, image.size.width, self.size.height), image.CGImage); 83 | 84 | UIImage *result = UIGraphicsGetImageFromCurrentImageContext(); 85 | 86 | UIGraphicsEndImageContext(); 87 | 88 | return result; 89 | } 90 | 91 | NS_INLINE UIImage *renderAnimationImages(NSMutableArray *container, UIImage *singleImage, BOOL right, CGFloat width, BOOL complete) { 92 | if (!width) { 93 | return nil; 94 | } 95 | 96 | CGFloat singleWidth = singleImage.size.width; 97 | 98 | UIImage *masterImage = (right ? container.lastObject : container.firstObject); 99 | 100 | if (complete || masterImage.size.width != width || !masterImage) { 101 | CGFloat expectedWidth = width+singleWidth*2.0f; 102 | 103 | BOOL completeReloop = (!masterImage || complete); 104 | 105 | if (completeReloop) { 106 | masterImage = [singleImage copy]; 107 | 108 | while (masterImage.size.width < expectedWidth) { 109 | masterImage = [masterImage attachImage:singleImage]; 110 | } 111 | } 112 | else { 113 | while (masterImage.size.width < expectedWidth) { 114 | masterImage = [masterImage attachImage:singleImage]; 115 | } 116 | while (masterImage.size.width-singleWidth > expectedWidth+singleWidth) { 117 | masterImage = [masterImage cropByX:singleWidth]; 118 | } 119 | } 120 | 121 | [container removeAllObjects]; 122 | 123 | CGSize size = CGSizeMake(width, masterImage.size.height); 124 | 125 | CGFloat pixels = singleWidth*[UIScreen mainScreen].scale; 126 | 127 | CGFloat anchorX = (right ? -fabsf(masterImage.size.width-width) : 0.0f); 128 | 129 | for (int i = 0; i <= pixels; i++) { 130 | UIGraphicsBeginImageContextWithOptions(size, NO, 0.0f); 131 | 132 | [masterImage drawInRect:(CGRect){{anchorX+(right ? i : -i), 0.0f}, masterImage.size}]; 133 | 134 | UIImage *result = UIGraphicsGetImageFromCurrentImageContext(); 135 | 136 | if (result) { 137 | [container addObject:result]; 138 | } 139 | 140 | UIGraphicsEndImageContext(); 141 | } 142 | } 143 | 144 | return masterImage; 145 | } 146 | 147 | @end 148 | 149 | @interface JGProgressView () { 150 | UIImageView *_imageView; 151 | 152 | CGFloat _cachedProgress; 153 | 154 | NSMutableArray *_animationImages; 155 | 156 | BOOL _updating; 157 | 158 | BOOL _animateToRight; 159 | } 160 | 161 | 162 | @end 163 | 164 | @implementation JGProgressView 165 | 166 | @synthesize animationImage = _animationImage; 167 | 168 | NS_INLINE void updateSharedProgressViewList(BOOL complete) { 169 | if (_updatingShared) { 170 | return; 171 | } 172 | 173 | if (!_sharedAnimationImages) { 174 | _sharedAnimationImages = [NSMutableArray array]; 175 | } 176 | 177 | BOOL doneRendering = NO; 178 | 179 | for (JGWeakReference *ref in _sharedProgressViews.copy) { 180 | if (!ref.object) { 181 | [_sharedProgressViews removeObject:ref]; 182 | } 183 | else { 184 | JGProgressView *prog = ref.object; 185 | 186 | prog.progressViewStyle = _sharedStyle; 187 | 188 | if (!doneRendering) { 189 | if (!_sharedImage) { 190 | if (iOS7) { 191 | CGSize size = (CGSize){27.5f, prog.frame.size.height}; 192 | 193 | UIGraphicsBeginImageContextWithOptions(size, NO, 0.0f); 194 | 195 | [prog.tintColor setFill]; 196 | 197 | [[UIBezierPath bezierPathWithRect:(CGRect){CGPointZero, {size.width/2.0f, size.height}}] fill]; 198 | 199 | _sharedImage = UIGraphicsGetImageFromCurrentImageContext(); 200 | 201 | UIGraphicsEndImageContext(); 202 | } 203 | else { 204 | if (_sharedStyle == UIProgressViewStyleDefault) { 205 | _sharedImage = [UIImage imageNamed:@"Indeterminate.png"]; 206 | } 207 | else { 208 | _sharedImage = [UIImage imageNamed:@"IndeterminateBar.png"]; 209 | } 210 | } 211 | } 212 | 213 | renderAnimationImages(_sharedAnimationImages, _sharedImage, _sharedAnimateToRight, prog.frame.size.width, complete); 214 | 215 | doneRendering = YES; 216 | } 217 | 218 | [prog updateImageView]; 219 | } 220 | } 221 | 222 | } 223 | 224 | 225 | + (void)beginUpdatingSharedProgressViews { 226 | _updatingShared = YES; 227 | } 228 | 229 | + (void)endUpdatingSharedProgressViews { 230 | _updatingShared = NO; 231 | updateSharedProgressViewList(NO); 232 | } 233 | 234 | 235 | + (void)setSharedProgressViewImage:(UIImage *)image { 236 | _sharedImage = image; 237 | _sharedAnimationImages = nil; 238 | 239 | updateSharedProgressViewList(YES); 240 | } 241 | 242 | + (void)setSharedProgressViewAnimationSpeed:(NSTimeInterval)speed { 243 | if (_sharedAnimationSpeed == speed) { 244 | return; 245 | } 246 | 247 | if ([[UIScreen mainScreen] respondsToSelector:@selector(scale)]) { 248 | _sharedAnimationSpeed = fabs(speed*[[UIScreen mainScreen] scale]); 249 | } 250 | else { 251 | _sharedAnimationSpeed = fabs(speed); 252 | } 253 | 254 | _sharedAnimateToRight = (speed < 0.0); 255 | 256 | updateSharedProgressViewList(NO); 257 | } 258 | 259 | 260 | + (void)setSharedProgressViewStyle:(UIProgressViewStyle)style { 261 | if (_sharedStyle == style) { 262 | return; 263 | } 264 | 265 | _sharedStyle = style; 266 | 267 | _sharedImage = nil; 268 | _sharedAnimationImages = nil; 269 | 270 | updateSharedProgressViewList(YES); 271 | } 272 | 273 | 274 | 275 | - (void)setUseSharedProperties:(BOOL)useSharedImages { 276 | if (_useSharedProperties == useSharedImages) { 277 | return; 278 | } 279 | 280 | _useSharedProperties = useSharedImages; 281 | 282 | if (_useSharedProperties) { 283 | if (!_sharedProgressViews) { 284 | _sharedProgressViews = [NSMutableSet set]; 285 | } 286 | 287 | JGWeakReference *ref = [JGWeakReference new]; 288 | ref.object = self; 289 | 290 | [_sharedProgressViews addObject:ref]; 291 | } 292 | else { 293 | for (JGWeakReference *ref in _sharedProgressViews.copy) { 294 | if (ref.object) { 295 | if (ref.object == self) { 296 | [_sharedProgressViews removeObject:ref]; 297 | break; 298 | } 299 | } 300 | else { 301 | [_sharedProgressViews removeObject:ref]; 302 | } 303 | } 304 | 305 | _animationImage = nil; 306 | _animationImages = nil; 307 | 308 | if (self.indeterminate) { 309 | [self reloopForInterfaceChange:YES]; 310 | } 311 | } 312 | } 313 | 314 | 315 | - (void)commonInit { 316 | [self setClipsToBounds:YES]; 317 | self.animationSpeed = 0.5f; 318 | } 319 | 320 | - (instancetype)initWithCoder:(NSCoder *)aDecoder { 321 | self = [super initWithCoder:aDecoder]; 322 | if (self) { 323 | [self commonInit]; 324 | } 325 | return self; 326 | } 327 | 328 | - (instancetype)initWithFrame:(CGRect)frame { 329 | self = [super initWithFrame:frame]; 330 | if (self) { 331 | [self commonInit]; 332 | } 333 | return self; 334 | } 335 | 336 | - (instancetype)initWithProgressViewStyle:(UIProgressViewStyle)style { 337 | self = [super initWithProgressViewStyle:style]; 338 | if (self) { 339 | [self commonInit]; 340 | } 341 | return self; 342 | } 343 | 344 | - (instancetype)init { 345 | self = [super init]; 346 | if (self) { 347 | [self commonInit]; 348 | } 349 | return self; 350 | } 351 | 352 | 353 | 354 | - (void)beginUpdates { 355 | _updating = YES; 356 | } 357 | 358 | - (void)endUpdates { 359 | _updating = NO; 360 | if (!_useSharedProperties) { 361 | [self reloopForInterfaceChange:NO]; 362 | } 363 | } 364 | 365 | 366 | - (UIImage *)makeAnimationImageForCurrentStyle { 367 | UIImage *img = nil; 368 | 369 | if (iOS7) { 370 | CGSize size = (CGSize){27.5f, self.frame.size.height}; 371 | 372 | UIGraphicsBeginImageContextWithOptions(size, NO, 0.0f); 373 | 374 | [self.tintColor setFill]; 375 | 376 | [[UIBezierPath bezierPathWithRect:(CGRect){CGPointZero, {size.width/2.0f, size.height}}] fill]; 377 | 378 | img = UIGraphicsGetImageFromCurrentImageContext(); 379 | 380 | UIGraphicsEndImageContext(); 381 | } 382 | else { 383 | if (self.progressViewStyle == UIProgressViewStyleDefault) { 384 | img = [UIImage imageNamed:@"Indeterminate.png"]; 385 | } 386 | else { 387 | img = [UIImage imageNamed:@"IndeterminateBar.png"]; 388 | } 389 | } 390 | 391 | return img; 392 | } 393 | 394 | 395 | - (UIImage *)animationImage { 396 | if (!_useSharedProperties) { 397 | if (!_animationImage) { 398 | _animationImage = [self makeAnimationImageForCurrentStyle]; 399 | } 400 | 401 | NSParameterAssert(_animationImage); 402 | 403 | return _animationImage; 404 | } 405 | 406 | return nil; 407 | } 408 | 409 | - (void)setAnimationImage:(UIImage *)animationImage { 410 | if (!_useSharedProperties) { 411 | if (animationImage != _animationImage) { 412 | [self willChangeValueForKey:@"animationImage"]; 413 | _animationImage = animationImage; 414 | 415 | _animationImages = nil; 416 | 417 | if (self.indeterminate) { 418 | [self reloopForInterfaceChange:YES]; 419 | } 420 | 421 | [self didChangeValueForKey:@"animationImage"]; 422 | } 423 | } 424 | } 425 | 426 | - (void)setAnimationSpeed:(NSTimeInterval)animationSpeed { 427 | if (!_useSharedProperties) { 428 | if ([[UIScreen mainScreen] respondsToSelector:@selector(scale)]) { 429 | _animationSpeed = fabs(animationSpeed*[[UIScreen mainScreen] scale]); 430 | } 431 | else { 432 | _animationSpeed = fabs(animationSpeed); 433 | } 434 | 435 | _animateToRight = (animationSpeed < 0.0); 436 | 437 | if (self.isIndeterminate) { 438 | [_imageView setAnimationDuration:self.animationSpeed]; 439 | } 440 | } 441 | } 442 | 443 | - (void)setProgressViewStyle:(UIProgressViewStyle)progressViewStyle { 444 | if (progressViewStyle == self.progressViewStyle) { 445 | return; 446 | } 447 | 448 | [super setProgressViewStyle:progressViewStyle]; 449 | 450 | if (!_useSharedProperties) { 451 | _animationImage = nil; 452 | _animationImages = nil; 453 | 454 | if (self.isIndeterminate) { 455 | [self reloopForInterfaceChange:YES]; 456 | } 457 | } 458 | } 459 | 460 | - (void)setTintColor:(UIColor *)tintColor { 461 | if ([tintColor isEqual:self.tintColor]) { 462 | return; 463 | } 464 | 465 | [super setTintColor:tintColor]; 466 | 467 | if (!_useSharedProperties) { 468 | _animationImage = nil; 469 | _animationImages = nil; 470 | 471 | if (self.isIndeterminate) { 472 | [self reloopForInterfaceChange:YES]; 473 | } 474 | } 475 | } 476 | 477 | - (void)setClipsToBounds:(BOOL)clipsToBounds { 478 | [super setClipsToBounds:YES]; 479 | } 480 | 481 | - (NSArray *)subviews { 482 | NSMutableArray *mutable = [[super subviews] mutableCopy]; 483 | [mutable removeObjectIdenticalTo:_imageView]; 484 | return [mutable copy]; 485 | } 486 | 487 | - (void)setFrame:(CGRect)frame { 488 | if (!_useSharedProperties) { 489 | CGSize oldSize = self.frame.size; 490 | 491 | [super setFrame:frame]; 492 | 493 | if (!CGSizeEqualToSize(oldSize, frame.size)) { 494 | if (self.isIndeterminate) { 495 | [self reloopForInterfaceChange:NO]; 496 | } 497 | } 498 | } 499 | else { 500 | [super setFrame:frame]; 501 | if (self.isIndeterminate) { 502 | [self layoutImageView]; 503 | } 504 | } 505 | } 506 | 507 | - (void)layoutImageView { 508 | [_imageView sizeToFit]; 509 | 510 | UIEdgeInsets insets = (!iOS7 && self.progressViewStyle == UIProgressViewStyleBar ? UIEdgeInsetsMake(1.0f, 1.0f, 2.0f, 1.0f) : UIEdgeInsetsZero); 511 | 512 | CGRect frame = UIEdgeInsetsInsetRect(self.bounds, insets); 513 | 514 | _imageView.frame = frame; 515 | 516 | if (!iOS7) { 517 | _imageView.layer.cornerRadius = frame.size.height/2.0f; 518 | } 519 | } 520 | 521 | #pragma mark - Progress Handling 522 | 523 | - (float)progress { 524 | if (self.isIndeterminate) { 525 | return _cachedProgress; 526 | } 527 | else { 528 | return [super progress]; 529 | } 530 | } 531 | 532 | - (void)setProgress:(float)progress animated:(BOOL)animated { 533 | if (self.isIndeterminate) { 534 | _cachedProgress = progress; 535 | } 536 | else { 537 | [super setProgress:progress animated:animated]; 538 | } 539 | } 540 | 541 | - (void)setProgress:(float)progress { 542 | if (self.isIndeterminate) { 543 | _cachedProgress = progress; 544 | } 545 | else { 546 | [super setProgress:progress]; 547 | } 548 | } 549 | 550 | 551 | #pragma mark - Indeterminate Handling 552 | 553 | 554 | - (void)setIndeterminate:(BOOL)indeterminate { 555 | if (_indeterminate == indeterminate) { 556 | return; 557 | } 558 | 559 | if (indeterminate) { 560 | _cachedProgress = self.progress; 561 | 562 | self.progress = 0.0f; 563 | } 564 | 565 | _indeterminate = indeterminate; 566 | 567 | if (_indeterminate) { 568 | if (!_useSharedProperties) { 569 | [self reloopForInterfaceChange:NO]; 570 | } 571 | else { 572 | [self updateImageView]; 573 | } 574 | } 575 | else { 576 | self.progress = _cachedProgress; 577 | 578 | [_imageView stopAnimating]; 579 | [_imageView removeFromSuperview]; 580 | _imageView = nil; 581 | } 582 | } 583 | 584 | - (void)renderAnimationImages:(BOOL)complete { 585 | if (!_animationImages) { 586 | _animationImages = [NSMutableArray array]; 587 | } 588 | 589 | renderAnimationImages(_animationImages, self.animationImage, _animateToRight, self.frame.size.width, complete); 590 | } 591 | 592 | - (void)reloopForInterfaceChange:(BOOL)complete { 593 | if (_updating) { 594 | return; 595 | } 596 | 597 | [self renderAnimationImages:YES]; 598 | 599 | [self updateImageView]; 600 | } 601 | 602 | - (void)updateImageView { 603 | if (self.indeterminate) { 604 | if (!_imageView) { 605 | _imageView = [[UIImageView alloc] init]; 606 | _imageView.layer.masksToBounds = YES; 607 | _imageView.clipsToBounds = YES; 608 | 609 | [self addSubview:_imageView]; 610 | } 611 | 612 | 613 | _imageView.animationImages = (_useSharedProperties ? _sharedAnimationImages : _animationImages); 614 | 615 | NSTimeInterval speed = (_useSharedProperties ? _sharedAnimationSpeed : self.animationSpeed); 616 | 617 | if (_imageView.animationDuration != speed) { 618 | _imageView.animationDuration = speed; 619 | } 620 | 621 | [self layoutImageView]; 622 | 623 | if (!_imageView.isAnimating) { 624 | [_imageView startAnimating]; 625 | } 626 | } 627 | else { 628 | [_imageView removeFromSuperview]; 629 | _imageView = nil; 630 | } 631 | } 632 | 633 | @end 634 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2012-2014 Jonas Gessner 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | this software and associated documentation files (the "Software"), to deal in 7 | the Software without restriction, including without limitation the rights to 8 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 9 | the Software, and to permit persons to whom the Software is furnished to do so, 10 | subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 17 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 19 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 20 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |

JGProgressView

© 2012-2014 Jonas Gessner
2 | 3 | ---------------- 4 |
5 | 6 |

7 | 8 |

9 | 10 | Setup 11 | ===== 12 | CocoaPods:
13 | Add this to your `Podfile`: 14 | ``` 15 | pod 'JGProgressView', '1.2.1' 16 | ``` 17 |

18 | OR: 19 |

20 | Add source Files:
21 | 1. Add the `JGProgressView` folder to your Xcode Project.
22 | 2. Add the **QuartzCore** framework to your project.
23 | 3. `#import "JGProgressView.h"`.
24 | 25 | Basic Usage 26 | =========== 27 | 28 | JGProgressView is used like a normal UIProgressView with the addition of a few properties: 29 | 30 | 31 | **BOOL indeterminate** 32 | 33 | Property for the indeterminate setting, default is NO, set to YES to start the indeterminate animation. 34 | 35 | 36 | 37 | **UIImage *animationImage** 38 | 39 | Use this property to set a custom image to use for the indeterminate animation. Set this to `nil` to use the standard image for the current UIProgressViewStyle. 40 | 41 | 42 | **NSTimeInterval animationSpeed** 43 | 44 | Adjust the speed of the animation. The higher the value is, the slower the animation becomes. The default value is 0.5, negative values will invert the animation direction. 45 | 46 | 47 | **beginUpdates** 48 | 49 | **endUpdates** 50 | 51 | Use begin- and endUpdates to increase performance when changing multiple properties of JGProgressView. 52 | 53 | 54 |
55 |
56 | 57 | **BOOL useSharedProperties** 58 | 59 | Defaults to NO. Set to YES to use shared image, animation speed and progress view style. This may help increasing performance when using many progress views with the same properties (ex. in a UITableViewCell). 60 | 61 |
62 | If `useSharedImages` is `YES`. Setting `animationImage` and `animationSpeed` or calling `beginUpdate`and `endUpdates`has no effects. Instead use the following methods to change the visuals of all JGProgressViews that have `useSharedProperties` set to `YES`. 63 | 64 | 65 | + (void)setSharedProgressViewAnimationSpeed:(NSTimeInterval)speed; 66 | + (void)setSharedProgressViewImage:(UIImage *)img; 67 | + (void)setSharedProgressViewStyle:(UIProgressViewStyle)style; 68 | 69 | + (void)beginUpdatingSharedProgressViews; 70 | + (void)endUpdatingSharedProgressViews; 71 | 72 | Demo 73 | ===== 74 | ```objc 75 | JGProgressView *progressView = [[JGProgressView alloc] init]; 76 | 77 | progressView.frame = CGRectMake(100.0f, 100.0f, 200.0f, progressView.frame.size.height); 78 | progressView.animationSpeed = 1.5; 79 | 80 | [self.view addSubview:progressView]; 81 | 82 | progressView.indeterminate = YES; 83 | ``` 84 | 85 | __*Important note if your project doesn't use ARC*: you must add the `-fobjc-arc` compiler flag to `JGProgressView.m` in Target Settings > Build Phases > Compile Sources.__ 86 | 87 | 88 | Credits 89 | ====== 90 | Created by Jonas Gessner. ©2012-2014 91 | 92 | 93 | License 94 | ===== 95 | 96 | JGProgressView is available under the MIT License. 97 | -------------------------------------------------------------------------------- /Raw.pxm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JonasGessner/JGProgressView/91470da3a0c1d92b29636448313913b3c446fc10/Raw.pxm --------------------------------------------------------------------------------