UIProgressView
2015-12-13 10:46
441 查看
UIProgressView顾名思义用来显示进度的,如音乐,视频的播放进度,和文件的上传下载进度等。
下面以一个简单的实例来介绍UIprogressView的使用。
@interface ActivityViewController : UIViewController
{
UIProgressView *proView;
double proValue;
NSTimer *timer;
}
@property(nonatomic, retain) UIProgressView *proView;
-(IBAction)btnStartClick;
@implementation ActivityViewController
@synthesize proView;
#pragma mark - View lifecycle
-(IBAction)btnStartClick
{
proValue=0;
timer = [NSTimerscheduledTimerWithTimeInterval:1target:selfselector:@selector(changeProgress) userInfo:nilrepeats:YES]; //利用计时器,每隔1秒调用一次(changeProgress)
}
-(void)changeProgress
{
proValue += 1.0; //改变proValue的值
if(proValue > 5)
{
//停用计时器
[timer invalidate];
}
else
{
[proViewsetProgress:(proValue / 5)];//重置进度条
}
}
- (void)viewDidLoad
{
proView = [[UIProgressViewalloc] initWithFrame:CGRectMake(100, 100, 150, 20)];
[proViewsetProgressViewStyle:UIProgressViewStyleDefault]; //设置进度条类型
[self.viewaddSubview:proView];
[superviewDidLoad];
}
下面以一个简单的实例来介绍UIprogressView的使用。
@interface ActivityViewController : UIViewController
{
UIProgressView *proView;
double proValue;
NSTimer *timer;
}
@property(nonatomic, retain) UIProgressView *proView;
-(IBAction)btnStartClick;
@implementation ActivityViewController
@synthesize proView;
#pragma mark - View lifecycle
-(IBAction)btnStartClick
{
proValue=0;
timer = [NSTimerscheduledTimerWithTimeInterval:1target:selfselector:@selector(changeProgress) userInfo:nilrepeats:YES]; //利用计时器,每隔1秒调用一次(changeProgress)
}
-(void)changeProgress
{
proValue += 1.0; //改变proValue的值
if(proValue > 5)
{
//停用计时器
[timer invalidate];
}
else
{
[proViewsetProgress:(proValue / 5)];//重置进度条
}
}
- (void)viewDidLoad
{
proView = [[UIProgressViewalloc] initWithFrame:CGRectMake(100, 100, 150, 20)];
[proViewsetProgressViewStyle:UIProgressViewStyleDefault]; //设置进度条类型
[self.viewaddSubview:proView];
[superviewDidLoad];
}
相关文章推荐
- UIActivityIndicatorView
- Leetcode: Range Sum Query - Immutable
- ios UIAlertController学习
- android SQLite中query的用法
- php 生成 ueediter 网页编辑器
- UIViewController的生命周期
- UI-第四讲:事件处理
- work_queue 函数调用栈
- UNIX环境高级编程--#include "apue.h"
- iOS开发之UITableView使用总结
- Agreeing to the Xcode/iOS license requires admin privileges, please re-run as root via sudo.
- 天龙源码学习【UI框架】1:Prefab信息管理类UIPathData
- Axzue注册码
- bind编译安装及压力测试
- NGUI使用Bitmap制作特殊数字
- 用百度编辑器发布新闻(UEditor的初始化开发部署)
- 使用JRadioButtonMenuItem组件
- JSP利用过滤器解决request中文乱码问题
- 两种缓解AndroidUI界面首次进入慢方式分析:Hanlder,AsyncTask
- Failover cluster configuration common issues