I want to use progress view using custom images for that i wrote following code in viewDidLoad
,
UIView *v = [[UIView alloc] initWithFrame:CGRectMake(20, 281, 260, 33)];
v.backgroundColor = [UIColor darkGrayColor];
progressTest = [[customprogress alloc] initWithFrame:CGRectMake(5, 9, 250, 15)];
progressTest.progress = 0.0;
[v addSubview:progressTest];
[self.view addSubview:v];
[NSTimer scheduledTimerWithTimeInterval:1.0 target:self selector:@selector(startProgressing) userInfo:nil repeats:YES];
and this is my customprogress.m file,
- (void)drawRect:(CGRect)rect {
UIImage *background = [[UIImage imageNamed:@"progressbarbg.png"]resizableImageWithCapInsets:UIEdgeInsetsMake(0, 5, 0, 4)];
UIImage *fill = [[UIImage imageNamed:@"progressbarfill.png"]resizableImageWithCapInsets:UIEdgeInsetsMake(0, 5, 0, 4)];
[background drawInRect:rect];
NSInteger maxWidth = rect.size.width;
NSInteger curWidth = floor([self progress] * maxWidth);
CGRect fillRect = CGRectMake(rect.origin.x,rect.origin.y+1,curWidth,rect.size.height-2);
[fill drawInRect:fillRect];
}
This is my startProgressing method
-(void) startProgressing {
float t = progressTest.progress;
seconds = (secondsLeft %3600) % 60;
progressTest.progress = t + seconds;
}
I am getting weird progress view which does not progress at all.I want to show progress view for 60 sec.How can i do that?
I am seeing just a rectangle with dark gray bgcolor.