Skip to content

Instantly share code, notes, and snippets.

@markSci5
Created August 21, 2013 10:56
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save markSci5/6293031 to your computer and use it in GitHub Desktop.
Save markSci5/6293031 to your computer and use it in GitHub Desktop.
Add progress bar to nav bar
- (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