Skip to content

Instantly share code, notes, and snippets.

@chrishulbert
Created August 22, 2011 10:18
Show Gist options
  • Save chrishulbert/1162080 to your computer and use it in GitHub Desktop.
Save chrishulbert/1162080 to your computer and use it in GitHub Desktop.
Progress bar in your navigation bar
// Display a progressbar
- (void)progress:(int)progress withMessage:(NSString*)message {
UIView* v = [[[UIView alloc] init] autorelease];
v.frame = CGRectMake(0, 0, 200, 30);
v.backgroundColor = [UIColor clearColor];
UILabel* lbl = [[[UILabel alloc] init] autorelease];
lbl.frame = CGRectMake(0,0, 200, 15);
lbl.backgroundColor = [UIColor clearColor];
lbl.textColor = [UIColor whiteColor];
lbl.shadowColor = [UIColor colorWithWhite:0 alpha:0.3];
lbl.shadowOffset = CGSizeMake(0, -1);
lbl.font = [UIFont boldSystemFontOfSize:12];
lbl.text = message;
lbl.textAlignment = UITextAlignmentCenter;
[v addSubview:lbl];
UIProgressView* pv = [[[UIProgressView alloc] initWithProgressViewStyle:UIProgressViewStyleBar] autorelease];
pv.frame = CGRectMake(0, 30-pv.frame.size.height, 200, pv.frame.size.height);
pv.progress = progress/100.0;
[v addSubview:pv];
self.navigationItem.titleView = v;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment