目录
13.UIActivityIndicatorView(进度环)
11.UISegmentedControl(分段控件)
1.Style(风格)
Plain(最普通)、Bordered(加边框)、Bar(工具条风格)
2.State(高亮)
3.Segments(整数,控件总共被分为几段)
4.Segment(选择指定的分段)
5.Title(各分段设置标题)
6.Image(分段设置图片)
7.Behavior(是否可用)
self.sc = [[UISegmentedControl alloc]initWithFrame:CGRectMake(20, 100, 200, 50)];
self.sc = [self.sc initWithItems:@[@"选项一",@"选项二",@"增加",@"删除"]];
[self.sc addTarget:self action:@selector(segmentChanged:) forControlEvents:UIControlEventValueChanged];
[self.view addSubview:self.sc];
//方法
- (IBAction)segmentChanged:(id)sender {
switch ([sender selectedSegmentIndex]) {
case 0:
self.view.backgroundColor = [UIColor redColor];
break;
case 1:
self.view.backgroundColor = [UIColor grayColor];
break;
case 2:
[self.sc insertSegmentWithTitle:@"选项四" atIndex:4 animated:YES];
break;
case 3:
[self.sc removeSegmentAtIndex:3 animated:YES];
break;
default:
break;
}
}
12.UIProgressView(进度条)
直接继承UIView,作为静态控件,向yoghurt战士某个耗时操作完成的百分比,不会参与用户交互。
1.Style(风格)
Default(默认)、Bar(工具条风格)
2.Progress(设置完成比例)
3.Progress Tint(已经完成进度的颜色)
4.Track Tint(进度条轨道颜色)
5.Progress Image(已经完成部分的图片)
6.Track Image(进度条轨道图片)
//创建
UIProgressView *progressView = [[UIProgressView alloc] initWithFrame:CGRectMake(50, 100, 250, 50)];
//背景颜色
progressView.backgroundColor = [UIColor grayColor];
//样式
progressView.progressViewStyle = UIProgressViewStyleBar;
//已完成进度颜色
progressView.progressTintColor = [UIColor greenColor];
//现在的进度
//_progressView.progress = 0.5;
//动画
[UIView animateWithDuration:5 animations:^{
[progressView setProgress:1 animated:YES];
} completion:^(BOOL finished){
if(f