本篇文章主要介绍了"UIProgressView进度条,UISlider滑动条,UISegmentedControl分隔栏的简单使用",主要涉及到计数器,插入数据方面的内容,对于移动开发感兴趣的同学可以参考一下:
UISegmentedControl是开发中经常会使用到,所以刚刚在学习的时候也重点的看了下该控件进度条和滑动条一半很少会使用到(下载的时候会经常使用到该属性)...
UISegmentedControl是开发中经常会使用到,所以刚刚在学习的时候也重点的看了下该控件
进度条和滑动条一半很少会使用到(下载的时候会经常使用到该属性),android的进度条和滑动的设置比ios复杂很多
先上图

1,进度条
/**进度条的使用
1.创建UIProGressView对象
2,创建定时器
3,将定时器的值与进度条的长度关联setProgress
4,释放对象
*/
//进度条的使用UIProgressView
progress=[[UIProgressView alloc]initWithFrame:CGRectMake(50, 250, 300, 150)];
progress.progressViewStyle=UIProgressViewStyleDefault;
progress.progressTintColor=[UIColor redColor];//设置进度条的颜色,下面设置了图片会覆盖掉该颜色
progress.trackTintColor=[UIColor grayColor];//设置背景柱状图的颜色
progress.progressImage=[UIImage imageNamed:@"login.png"];//图片替代进度条
progress.transform=CGAffineTransformMakeScale(1.0f, 100.0f);//设置进度条的高度
[self.view addSubview:progress];
[progress release];
// //创建定时器,一秒执行一次
time=[NSTimer scheduledTimerWithTimeInterval:1 target:self selector:@selector(show) userInfo:nil repeats:1];
proValue=1.0;
方法:
//点击事件
-(void)show{
// NameBean *bean=[[NameBean alloc]init];
// bean.name=@"百合不是茶next";
// bean.address=@"湖南next";
// bean.age=122;
//
// ViewController *vc =[[ViewController alloc]init];
// [delegate getOneNameBean:bean];//设置代理数据
// [self.navigationController pushViewController:vc animated:1];
//
// [bean release];
// [vc release];
++proValue;
if (proValue>10) {
//停止定时器
[time invalidate];
//计数器停止后,进度条重置
[progress setProgress:0];
}else{
//进度条停止前进
[progress setProgress:proValue/10];
}
注意:
进度条的方法使用了定时器,事件处理也是在定时器中操作的
NSTimer *time=[NSTimer scheduledTimerWithTimeInterval:1 target:self selector:@selector(show) userInfo:nil repeats:1];
2,滑动条