user214155 user214155 - 4 months ago 59
iOS Question

Objective-C: Progress view programmatically

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

Answer

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

KAProgressLabel

Circular Progress View

Progress View Using Bezir Path

Comments