
上QQ阅读APP看书,第一时间看更新
2.11 进度条控件——UIProgressView
UIKit框架中的UIProgressView控件可以创建一个进度条,这个控件在播放器类软件中较为常见,使用Xcode 创建一个名为UIProgressViewTest 的工程,在ViewController.m 文件的viewDidLoad方法中添加如下代码:
- (void)viewDidLoad { [super viewDidLoad]; UIProgressView * progressView = [[UIProgressView alloc]initWithFrame:C GRectMake(20, 100, 280, 30)]; progressView.progressTintColor = [UIColor redColor]; progressView.trackTintColor = [UIColor blueColor]; [self.view addSubview:progressView]; progressView.progress = 0.5; }
progressTintColor属性设置已走过进度的颜色,trackTintColor属性设置未走过的进度的颜色,progress属设置进度条当前的进度,取值为0~1之间的浮点数。运行上面代码后,效果如图2-36所示。

图2-36 UIProgressView控件