Reputation: 111
How can I create progressView
programmatically with height 50 and rounded corners in my Xcode project?
if I use this code
CGAffineTransform transform = CGAffineTransformMakeScale(1.0f, 3.0f);
progressView.transform = transform;
rounded corners disappear
Upvotes: 0
Views: 13313
Reputation: 9589
I tried getting progress view with rounded corners.I got it.
First you need to add and import
#import <QuartzCore/QuartzCore.h>
Then
UIProgressView *progressView;
progressView = [[UIProgressView alloc] initWithProgressViewStyle:UIProgressViewStyleDefault];
progressView.progressTintColor = [UIColor colorWithRed:187.0/255 green:160.0/255 blue:209.0/255 alpha:1.0];
[[progressView layer]setFrame:CGRectMake(20, 50, 200, 200)];
[[progressView layer]setBorderColor:[UIColor redColor].CGColor];
progressView.trackTintColor = [UIColor clearColor];
[progressView setProgress:(float)(50/100) animated:YES]; ///15
[[progressView layer]setCornerRadius:progressView.frame.size.width / 2];
[[progressView layer]setBorderWidth:3];
[[progressView layer]setMasksToBounds:TRUE];
progressView.clipsToBounds = YES;
[self.view addSubview:progressView];
Also
Progress View Using Bezir Path
Upvotes: 2
Reputation: 1698
You can use this code:
UIProgressView *progressView = [[UIProgressView alloc] initWithProgressViewStyle:UIProgressViewStyleBar];
progressView.progress = 0.75f;
[progressView.layer setCornerRadius:10];
progressView.layer.masksToBounds = TRUE;
progressView.clipsToBounds = TRUE;
CGAffineTransform transform = CGAffineTransformMakeScale(1.0f, 10.0f);
progressView.transform = transform;
[self.view addSubview: progressView];
Upvotes: 0
Reputation: 778
UIProgressView *progressView = [[UIProgressView alloc] initWithProgressViewStyle:whateverStyle]
progressView.progress = 0.75f;
//setting height and corner
[[UIProgressView appearance] setFrame:CGRectMake(20, 100, 280, 50)];
[progressView.layer setCornerRadius:4];
progressView.layer.masksToBounds = TRUE;
progressView.clipsToBounds = TRUE;
[self.view addSubview: progressView]
Upvotes: 0