diff --git a/TWRProgressViewDemo/ProgressView.xcodeproj/project.pbxproj b/TWRProgressViewDemo/ProgressView.xcodeproj/project.pbxproj index f49f80c..8bf53bc 100644 --- a/TWRProgressViewDemo/ProgressView.xcodeproj/project.pbxproj +++ b/TWRProgressViewDemo/ProgressView.xcodeproj/project.pbxproj @@ -23,6 +23,8 @@ 155E750D187E048E00AFCD05 /* ProgressViewTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 155E750C187E048E00AFCD05 /* ProgressViewTests.m */; }; 155E7518187E049800AFCD05 /* TWRProgressView.m in Sources */ = {isa = PBXBuildFile; fileRef = 155E7517187E049800AFCD05 /* TWRProgressView.m */; }; 155E751A187E278700AFCD05 /* QuartzCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 155E7519187E278700AFCD05 /* QuartzCore.framework */; }; + 64A0073F1AC03842005C067C /* TWRExampleView.m in Sources */ = {isa = PBXBuildFile; fileRef = 64A0073E1AC03842005C067C /* TWRExampleView.m */; }; + 64A007461AC03884005C067C /* TWRExampleViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 64A007451AC03884005C067C /* TWRExampleViewController.m */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -58,6 +60,10 @@ 155E7516187E049800AFCD05 /* TWRProgressView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TWRProgressView.h; sourceTree = ""; }; 155E7517187E049800AFCD05 /* TWRProgressView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TWRProgressView.m; sourceTree = ""; }; 155E7519187E278700AFCD05 /* QuartzCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = QuartzCore.framework; path = System/Library/Frameworks/QuartzCore.framework; sourceTree = SDKROOT; }; + 64A0073D1AC03842005C067C /* TWRExampleView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TWRExampleView.h; sourceTree = ""; }; + 64A0073E1AC03842005C067C /* TWRExampleView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TWRExampleView.m; sourceTree = ""; }; + 64A007441AC03884005C067C /* TWRExampleViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TWRExampleViewController.h; sourceTree = ""; }; + 64A007451AC03884005C067C /* TWRExampleViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TWRExampleViewController.m; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -119,14 +125,9 @@ 155E74E7187E048E00AFCD05 /* ProgressView */ = { isa = PBXGroup; children = ( - 155E74F0187E048E00AFCD05 /* TWRAppDelegate.h */, - 155E74F1187E048E00AFCD05 /* TWRAppDelegate.m */, - 155E74F3187E048E00AFCD05 /* Main.storyboard */, - 155E74F6187E048E00AFCD05 /* TWRViewController.h */, - 155E74F7187E048E00AFCD05 /* TWRViewController.m */, - 155E7516187E049800AFCD05 /* TWRProgressView.h */, - 155E7517187E049800AFCD05 /* TWRProgressView.m */, - 155E74F9187E048E00AFCD05 /* Images.xcassets */, + 64A0073B1AC0369F005C067C /* ProgressView */, + 64A0073A1AC03681005C067C /* Example */, + 64A0073C1AC036AD005C067C /* Resources */, 155E74E8187E048E00AFCD05 /* Supporting Files */, ); path = ProgressView; @@ -161,6 +162,71 @@ name = "Supporting Files"; sourceTree = ""; }; + 64A0073A1AC03681005C067C /* Example */ = { + isa = PBXGroup; + children = ( + 155E74F0187E048E00AFCD05 /* TWRAppDelegate.h */, + 155E74F1187E048E00AFCD05 /* TWRAppDelegate.m */, + 155E74F3187E048E00AFCD05 /* Main.storyboard */, + 64A007411AC0384C005C067C /* Controllers */, + ); + name = Example; + sourceTree = ""; + }; + 64A0073B1AC0369F005C067C /* ProgressView */ = { + isa = PBXGroup; + children = ( + 155E7516187E049800AFCD05 /* TWRProgressView.h */, + 155E7517187E049800AFCD05 /* TWRProgressView.m */, + ); + name = ProgressView; + sourceTree = ""; + }; + 64A0073C1AC036AD005C067C /* Resources */ = { + isa = PBXGroup; + children = ( + 155E74F9187E048E00AFCD05 /* Images.xcassets */, + ); + name = Resources; + sourceTree = ""; + }; + 64A007401AC03846005C067C /* Views */ = { + isa = PBXGroup; + children = ( + 64A0073D1AC03842005C067C /* TWRExampleView.h */, + 64A0073E1AC03842005C067C /* TWRExampleView.m */, + ); + name = Views; + sourceTree = ""; + }; + 64A007411AC0384C005C067C /* Controllers */ = { + isa = PBXGroup; + children = ( + 64A007431AC0385F005C067C /* StoryboardViewController */, + 64A007421AC03852005C067C /* CodeViewController */, + ); + name = Controllers; + sourceTree = ""; + }; + 64A007421AC03852005C067C /* CodeViewController */ = { + isa = PBXGroup; + children = ( + 64A007401AC03846005C067C /* Views */, + 64A007441AC03884005C067C /* TWRExampleViewController.h */, + 64A007451AC03884005C067C /* TWRExampleViewController.m */, + ); + name = CodeViewController; + sourceTree = ""; + }; + 64A007431AC0385F005C067C /* StoryboardViewController */ = { + isa = PBXGroup; + children = ( + 155E74F6187E048E00AFCD05 /* TWRViewController.h */, + 155E74F7187E048E00AFCD05 /* TWRViewController.m */, + ); + name = StoryboardViewController; + sourceTree = ""; + }; /* End PBXGroup section */ /* Begin PBXNativeTarget section */ @@ -260,6 +326,8 @@ buildActionMask = 2147483647; files = ( 155E74F8187E048E00AFCD05 /* TWRViewController.m in Sources */, + 64A007461AC03884005C067C /* TWRExampleViewController.m in Sources */, + 64A0073F1AC03842005C067C /* TWRExampleView.m in Sources */, 155E7518187E049800AFCD05 /* TWRProgressView.m in Sources */, 155E74F2187E048E00AFCD05 /* TWRAppDelegate.m in Sources */, 155E74EE187E048E00AFCD05 /* main.m in Sources */, @@ -471,6 +539,7 @@ 155E7512187E048E00AFCD05 /* Release */, ); defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; }; 155E7513187E048E00AFCD05 /* Build configuration list for PBXNativeTarget "ProgressViewTests" */ = { isa = XCConfigurationList; @@ -479,6 +548,7 @@ 155E7515187E048E00AFCD05 /* Release */, ); defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; }; /* End XCConfigurationList section */ }; diff --git a/TWRProgressViewDemo/ProgressView/Base.lproj/Main.storyboard b/TWRProgressViewDemo/ProgressView/Base.lproj/Main.storyboard index 7b0a02f..25279d9 100644 --- a/TWRProgressViewDemo/ProgressView/Base.lproj/Main.storyboard +++ b/TWRProgressViewDemo/ProgressView/Base.lproj/Main.storyboard @@ -1,13 +1,14 @@ - + - + + - + @@ -17,13 +18,18 @@ - - + + + + + - - - - - - - - - - - - - - - + + + + + + + + + + @@ -75,4 +95,4 @@ - \ No newline at end of file + diff --git a/TWRProgressViewDemo/ProgressView/Images.xcassets/AppIcon.appiconset/Contents.json b/TWRProgressViewDemo/ProgressView/Images.xcassets/AppIcon.appiconset/Contents.json index a396706..33ec0bc 100644 --- a/TWRProgressViewDemo/ProgressView/Images.xcassets/AppIcon.appiconset/Contents.json +++ b/TWRProgressViewDemo/ProgressView/Images.xcassets/AppIcon.appiconset/Contents.json @@ -14,6 +14,11 @@ "idiom" : "iphone", "size" : "60x60", "scale" : "2x" + }, + { + "idiom" : "iphone", + "size" : "60x60", + "scale" : "3x" } ], "info" : { diff --git a/TWRProgressViewDemo/ProgressView/Images.xcassets/document_icon.imageset/Contents.json b/TWRProgressViewDemo/ProgressView/Images.xcassets/document_icon.imageset/Contents.json index a0742a4..95bf1ae 100644 --- a/TWRProgressViewDemo/ProgressView/Images.xcassets/document_icon.imageset/Contents.json +++ b/TWRProgressViewDemo/ProgressView/Images.xcassets/document_icon.imageset/Contents.json @@ -8,6 +8,10 @@ { "idiom" : "universal", "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" } ], "info" : { diff --git a/TWRProgressViewDemo/ProgressView/Images.xcassets/social_icon.imageset/Contents.json b/TWRProgressViewDemo/ProgressView/Images.xcassets/social_icon.imageset/Contents.json index 58b86d7..8288b1c 100644 --- a/TWRProgressViewDemo/ProgressView/Images.xcassets/social_icon.imageset/Contents.json +++ b/TWRProgressViewDemo/ProgressView/Images.xcassets/social_icon.imageset/Contents.json @@ -8,6 +8,10 @@ { "idiom" : "universal", "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" } ], "info" : { diff --git a/TWRProgressViewDemo/ProgressView/ProgressView-Info.plist b/TWRProgressViewDemo/ProgressView/ProgressView-Info.plist index 61fd52f..275b8a5 100644 --- a/TWRProgressViewDemo/ProgressView/ProgressView-Info.plist +++ b/TWRProgressViewDemo/ProgressView/ProgressView-Info.plist @@ -24,8 +24,6 @@ 1.0 LSRequiresIPhoneOS - UIMainStoryboardFile - Main UIRequiredDeviceCapabilities armv7 @@ -35,6 +33,7 @@ UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight + UIInterfaceOrientationPortraitUpsideDown diff --git a/TWRProgressViewDemo/ProgressView/TWRAppDelegate.m b/TWRProgressViewDemo/ProgressView/TWRAppDelegate.m index 62e2546..ddc0468 100644 --- a/TWRProgressViewDemo/ProgressView/TWRAppDelegate.m +++ b/TWRProgressViewDemo/ProgressView/TWRAppDelegate.m @@ -7,12 +7,26 @@ // #import "TWRAppDelegate.h" +#import "TWRExampleViewController.h" @implementation TWRAppDelegate -- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions -{ - // Override point for customization after application launch. +- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { + // create the window + self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; + [self.window setBackgroundColor:[UIColor whiteColor]]; + [self.window makeKeyAndVisible]; + + // set root controllers + UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil]; + UIViewController *storyboardViewController = [storyboard instantiateViewControllerWithIdentifier:@"TWRMainStoryboard"]; + UIViewController *codeViewController = [[TWRExampleViewController alloc] init]; + + UITabBarController *tabBarController = [[UITabBarController alloc] init]; + [tabBarController setViewControllers:@[storyboardViewController, codeViewController]]; + [self.window setRootViewController:tabBarController]; + + // finish launching return YES; } diff --git a/TWRProgressViewDemo/ProgressView/TWRExampleView.h b/TWRProgressViewDemo/ProgressView/TWRExampleView.h new file mode 100644 index 0000000..24ea62a --- /dev/null +++ b/TWRProgressViewDemo/ProgressView/TWRExampleView.h @@ -0,0 +1,16 @@ +// +// TWRExampleView.h +// ProgressView +// +// Created by Natalia Osiecka on 23.3.2015. +// Copyright (c) 2015 Touchware. All rights reserved. +// + +#import +#import "TWRProgressView.h" + +@interface TWRExampleView : UIView + +@property (nonatomic, readonly) TWRProgressView *progressView; + +@end diff --git a/TWRProgressViewDemo/ProgressView/TWRExampleView.m b/TWRProgressViewDemo/ProgressView/TWRExampleView.m new file mode 100644 index 0000000..df8f795 --- /dev/null +++ b/TWRProgressViewDemo/ProgressView/TWRExampleView.m @@ -0,0 +1,36 @@ +// +// TWRExampleView.m +// ProgressView +// +// Created by Natalia Osiecka on 23.3.2015. +// Copyright (c) 2015 Touchware. All rights reserved. +// + +#import "TWRExampleView.h" + +@implementation TWRExampleView + +- (instancetype)initWithFrame:(CGRect)frame { + if (self = [super initWithFrame:frame]) { + _progressView = [[TWRProgressView alloc] initWithFrame:frame andMaskingImage:[UIImage imageNamed:@"social_icon"]]; + [_progressView setBackColor:[UIColor greenColor]]; + [_progressView setFrontColor:[UIColor blueColor]]; + [_progressView setProgress:0.f]; + [self addSubview:_progressView]; + } + + return self; +} + +- (void)layoutSubviews { + [super layoutSubviews]; + + CGRect frame = self.bounds; + CGSize progressViewSize = CGSizeMake(100.f, 100.f); + [self.progressView setFrame:CGRectIntegral(CGRectMake(CGRectGetMidX(frame) - progressViewSize.width / 2, + CGRectGetMidY(frame) - progressViewSize.height / 2, + progressViewSize.width, + progressViewSize.height))]; +} + +@end diff --git a/TWRProgressViewDemo/ProgressView/TWRExampleViewController.h b/TWRProgressViewDemo/ProgressView/TWRExampleViewController.h new file mode 100644 index 0000000..10d647a --- /dev/null +++ b/TWRProgressViewDemo/ProgressView/TWRExampleViewController.h @@ -0,0 +1,13 @@ +// +// TWRExampleViewController.h +// ProgressView +// +// Created by Natalia Osiecka on 23.3.2015. +// Copyright (c) 2015 Touchware. All rights reserved. +// + +#import + +@interface TWRExampleViewController : UIViewController + +@end diff --git a/TWRProgressViewDemo/ProgressView/TWRExampleViewController.m b/TWRProgressViewDemo/ProgressView/TWRExampleViewController.m new file mode 100644 index 0000000..99b60c9 --- /dev/null +++ b/TWRProgressViewDemo/ProgressView/TWRExampleViewController.m @@ -0,0 +1,75 @@ +// +// TWRExampleViewController.m +// ProgressView +// +// Created by Natalia Osiecka on 23.3.2015. +// Copyright (c) 2015 Touchware. All rights reserved. +// + +#import "TWRExampleViewController.h" +#import "TWRExampleView.h" + +@interface TWRExampleViewController () + +@property (nonatomic, weak, readonly) TWRExampleView *aView; +@property (nonatomic, readonly) NSTimer *timer; +@property (nonatomic) CGFloat progress; + +@end + +@implementation TWRExampleViewController + +#pragma mark - Memory management + +- (instancetype)init { + if (self = [super init]) { + [self setTitle:@"Code"]; + } + + return self; +} + +#pragma mark - View lifecycle + +- (void)loadView { + CGRect rect = [[UIScreen mainScreen] applicationFrame]; + TWRExampleView *view = [[TWRExampleView alloc] initWithFrame:rect]; + [view setAutoresizingMask:UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth]; + + // local for easier access + _aView = view; + self.view = view; +} + +- (void)viewWillAppear:(BOOL)animated { + [super viewWillAppear:animated]; + + self.progress = 0.f; + _timer = [NSTimer scheduledTimerWithTimeInterval:0.1 target:self selector:@selector(timerAction:) userInfo:nil repeats:YES]; +} + +- (void)viewWillDisappear:(BOOL)animated { + [super viewWillDisappear:animated]; + + [_timer invalidate]; +} + +#pragma mark - Actions + +- (void)timerAction:(NSTimer *)timer { + [self.aView.progressView setProgress:self.progress]; + + if (isFloatMore(self.progress, 1.f)) { + self.progress = 0.f; + } else { + self.progress += 0.01; + } +} + +#pragma mark - Others + +BOOL isFloatMore(CGFloat x, CGFloat y) { + return (x > y - FLT_EPSILON); +} + +@end diff --git a/TWRProgressViewDemo/ProgressView/TWRProgressView.h b/TWRProgressViewDemo/ProgressView/TWRProgressView.h index aab3109..a65d8d6 100644 --- a/TWRProgressViewDemo/ProgressView/TWRProgressView.h +++ b/TWRProgressViewDemo/ProgressView/TWRProgressView.h @@ -14,21 +14,40 @@ CGFloat _animationTime; } +/** + * Gradient layer applied to view. + */ @property (nonatomic, readonly) CAGradientLayer *gradientLayer; -// An Array of UIColors for the gradient -@property (nonatomic, readwrite) NSArray *colors UI_APPEARANCE_SELECTOR; - -// Simple colors -@property (nonatomic, readwrite) UIColor *backColor UI_APPEARANCE_SELECTOR; -@property (nonatomic, readwrite) UIColor *frontColor UI_APPEARANCE_SELECTOR; - -// Specifies that the gradient should be drawn horizontally -@property (nonatomic, getter = isHorizontal) BOOL horizontal; - -@property (nonatomic, strong) UIImage *maskingImage UI_APPEARANCE_SELECTOR; - -@property (nonatomic, assign) CGFloat progress; +/** + * An Array of UIColors for the gradient. + */ +@property (nonatomic) NSArray *colors UI_APPEARANCE_SELECTOR; + +/** + * Color of 'empty' part of the progress. + */ +@property (nonatomic) UIColor *backColor UI_APPEARANCE_SELECTOR; + +/** + * Color of 'filled' part of the progress. + */ +@property (nonatomic) UIColor *frontColor UI_APPEARANCE_SELECTOR; + +/** + * Specifies that the gradient should be drawn horizontally. + */ +@property (nonatomic) BOOL horizontal; + +/** + * The mask image, where progress is applied. + */ +@property (nonatomic) UIImage *maskingImage UI_APPEARANCE_SELECTOR; + +/** + * Percentage of which the view is filled from the bottom (0%) to top (100%). + */ +@property (nonatomic) CGFloat progress; + (instancetype)progressViewWithFrame:(CGRect)frame andMaskingImage:(UIImage *)maskingImage; - (instancetype)initWithFrame:(CGRect)frame andMaskingImage:(UIImage *)maskingImage; diff --git a/TWRProgressViewDemo/ProgressView/TWRProgressView.m b/TWRProgressViewDemo/ProgressView/TWRProgressView.m index f78bbbd..8836c73 100644 --- a/TWRProgressViewDemo/ProgressView/TWRProgressView.m +++ b/TWRProgressViewDemo/ProgressView/TWRProgressView.m @@ -14,15 +14,17 @@ @implementation TWRProgressView +#pragma mark - Class methods + + (instancetype)progressViewWithFrame:(CGRect)frame andMaskingImage:(UIImage *)maskingImage { return [[self alloc] initWithFrame:frame andMaskingImage:maskingImage]; } -- (instancetype)initWithFrame:(CGRect)frame -{ +#pragma mark - Memory management + +- (instancetype)initWithFrame:(CGRect)frame { self = [super initWithFrame:frame]; if (self) { - // Initialization code [self commonInit]; } return self; @@ -36,10 +38,9 @@ - (instancetype)initWithFrame:(CGRect)frame andMaskingImage:(UIImage *)maskingIm return self; } --(instancetype)initWithCoder:(NSCoder *)aDecoder { +- (instancetype)initWithCoder:(NSCoder *)aDecoder { self = [super initWithCoder:aDecoder]; if (self) { - // Initialization code [self commonInit]; } return self; @@ -52,21 +53,27 @@ - (void)commonInit { [self setColors:@[[UIColor grayColor], [UIColor redColor]]]; } +#pragma mark - Layout + +- (void)layoutSubviews { + [super layoutSubviews]; + + [self maskView:self]; +} + #pragma mark - Layer -+ (Class)layerClass -{ ++ (Class)layerClass { return [CAGradientLayer class]; } -- (CAGradientLayer *)gradientLayer -{ +- (CAGradientLayer *)gradientLayer { return (CAGradientLayer *)self.layer; } - (void)maskView:(UIView *)viewToBeMasked { // Won't work with jpg - UIImage* imageWithAlphaChannel = _maskingImage; //[UIImage imageNamed:@"document_icon"]; + UIImage* imageWithAlphaChannel = _maskingImage; CGImageRef cgImageWithAlpha = [imageWithAlphaChannel CGImage]; CALayer* maskingLayer = [CALayer layer]; maskingLayer.contents = (__bridge id)cgImageWithAlpha; @@ -80,13 +87,7 @@ - (void)maskView:(UIView *)viewToBeMasked { #pragma mark - Properties settings -- (void)setMaskingImage:(UIImage *)maskingImage { - _maskingImage = maskingImage; - [self maskView:self]; -} - -- (void)setColors:(NSArray *)colors -{ +- (void)setColors:(NSArray *)colors { NSMutableArray *cgColors = [NSMutableArray arrayWithCapacity:colors.count]; for (UIColor *color in colors) { [cgColors addObject:(id)[color CGColor]]; @@ -95,11 +96,9 @@ - (void)setColors:(NSArray *)colors self.gradientLayer.colors = cgColors; } -- (NSArray *)colors -{ +- (NSArray *)colors { NSMutableArray *uiColors = [NSMutableArray arrayWithCapacity:self.gradientLayer.colors.count]; - for (id color in self.gradientLayer.colors) - { + for (id color in self.gradientLayer.colors) { [uiColors addObject:[UIColor colorWithCGColor:(CGColorRef)color]]; } @@ -109,7 +108,7 @@ - (NSArray *)colors - (void)setBackColor:(UIColor *)backColor { NSMutableArray *currentColors = [self colors].mutableCopy; if (currentColors.count > 0) { - [currentColors replaceObjectAtIndex:0 withObject:backColor]; + currentColors[0] = backColor; [self setColors:currentColors]; } [self setNeedsDisplay]; @@ -122,7 +121,7 @@ - (UIImage *)backColor { - (void)setFrontColor:(UIColor *)frontColor { NSMutableArray *currentColors = [self colors].mutableCopy; if (currentColors.count > 0) { - [currentColors replaceObjectAtIndex:1 withObject:frontColor]; + currentColors[1] = frontColor; [self setColors:currentColors]; } [self setNeedsDisplay]; @@ -132,14 +131,12 @@ - (UIColor *)frontColor { return self.colors[1]; } -- (void)setHorizontal:(BOOL)horizontal -{ +- (void)setHorizontal:(BOOL)horizontal { self.gradientLayer.startPoint = horizontal ? HORIZONTAL_START_POINT : VERTICAL_START_POINT; self.gradientLayer.endPoint = horizontal ? HORIZONTAL_END_POINT : VERTICAL_END_POINT; } -- (BOOL)isHorizontal -{ +- (BOOL)isHorizontal { return (CGPointEqualToPoint(self.gradientLayer.startPoint, HORIZONTAL_START_POINT)) && (CGPointEqualToPoint(self.gradientLayer.endPoint, HORIZONTAL_END_POINT)); } @@ -149,13 +146,11 @@ - (void)setAnimationTime:(CGFloat)time { #pragma mark - Progress -- (void)setProgress:(CGFloat)progress -{ +- (void)setProgress:(CGFloat)progress { [self setProgress:progress animated:NO]; } -- (void)setProgress:(CGFloat)progress animated:(BOOL)animated -{ +- (void)setProgress:(CGFloat)progress animated:(BOOL)animated { CGFloat normalizedProgress = 1 - MIN(MAX(progress, 0.f), 1.f); NSArray* newLocations = @[@(normalizedProgress), @(normalizedProgress)]; diff --git a/TWRProgressViewDemo/ProgressView/TWRViewController.m b/TWRProgressViewDemo/ProgressView/TWRViewController.m index 3b0b8e5..fb5edfd 100644 --- a/TWRProgressViewDemo/ProgressView/TWRViewController.m +++ b/TWRProgressViewDemo/ProgressView/TWRViewController.m @@ -24,6 +24,16 @@ - (IBAction)decrement:(id)sender; @implementation TWRViewController +- (instancetype)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil +{ + if (self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]) + { + [self setTitle:@"Storyboard"]; + } + + return self; +} + - (void)viewDidLoad { [super viewDidLoad];