簡體   English   中英

Objective-C:以編程方式查看進度

[英]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];

KAProgressLabel

循環進度視圖

使用Bezir路徑的進度視圖

 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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM