https://www.jianshu.com/p/0295e0fac7f5
//
// ViewController.m
// UIProgressView-进度条控件
//
// Created by Liu,Wenbo(TBRD) on 2020/5/28.
// Copyright © 2020 Liu,Wenbo(TBRD). All rights reserved.
//
#import "ViewController.h"
@interface ViewController ()
{
UIProgressView *progressView;
}
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view.
progressView = [[UIProgressView alloc] initWithFrame:CGRectMake(80, 100, 200, 100)];
//设置进度条的值
//progressView.progress = 0.7; //取值范围是0-1(float)
[progressView setProgress:0.7 animated:YES];//设置进度条的值并显示动画
// 设置走过的进度条的颜色
progressView.progressTintColor = [UIColor redColor];
//设置未走的进度条的颜色
progressView.trackTintColor = [UIColor greenColor];
//设置进度条的背景图片
// pro.trackImage=[UIImage imageNamed:@"1"];
//设置进度条上进度的背景图片 IOS7后好像没有效果了)
[self.view addSubview: progressView];
}
-(void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{
[progressView setProgress:arc4random()%10/10.0 animated:YES];
}
@end