[英]Objective-C: Progress view programmatically
如何在Xcode项目中以高度50和圆角编程地创建progressView
?
如果我使用这段代码
CGAffineTransform transform = CGAffineTransformMakeScale(1.0f, 3.0f);
progressView.transform = transform;
圆角消失
我试图获得带有圆角的进度视图。
首先,您需要添加和导入
#import <QuartzCore/QuartzCore.h>
然后
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];
也
UIProgressView *progressView = [[UIProgressView alloc] initWithProgressViewStyle:whateverStyle]
progressView.progress = 0.75f;
//设置高度和角
[[UIProgressView appearance] setFrame:CGRectMake(20, 100, 280, 50)];
[progressView.layer setCornerRadius:4];
progressView.layer.masksToBounds = TRUE;
progressView.clipsToBounds = TRUE;
[self.view addSubview: progressView]
您可以使用以下代码:
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];
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.