状态栏显示进度加载
来源:互联网 发布:淘宝上传视频要求 编辑:程序博客网 时间:2024/05/22 14:06
子类化UIWindow,在状态栏上创建UIProgressView加载进度条,创建UILabel显示文字
//StatusBarWindow.h
@interface StatusBarWindow :UIWindow
{
UIProgressView *_progressView;
UILabel *_sendLabel;
}
//显示状态栏进度加载
- (void)showProgressView:(NSString *)text show:(BOOL)show operation:(AFHTTPRequestOperation *)operation;
//隐藏
- (void)hidden;
#import "StatusBarWindow.h"
#import "UIProgressView+AFNetworking.h"
@implementation StatusBarWindow
- (instancetype)initWithFrame:(CGRect)frame
{
self = [superinitWithFrame:frame];
if (self) {
//设置window的优先级
self.windowLevel =UIWindowLevelStatusBar;
//设置背景颜色
self.backgroundColor = [UIColorblackColor];
}
returnself;
}
//显示状态栏进度加载
- (void)showProgressView:(NSString *)text show:(BOOL)show operation:(AFHTTPRequestOperation *)operation
{
//创建加载进度条
//做安全判断,如果已经创建,则不再重复创建
if (_progressView ==nil) {
_progressView = [[UIProgressViewalloc] initWithFrame:CGRectMake(0,15, kScreenWidth,5)];
}
[selfaddSubview:_progressView];
//创建sendLabel显示文字,正在加载,加载成功
//做安全判断,如果已经创建,则不再重复创建
if (_sendLabel ==nil) {
_sendLabel = [[UILabelalloc] initWithFrame:CGRectMake(0,0, kScreenWidth,15)];
//字体大小
_sendLabel.font = [UIFontsystemFontOfSize:11];
_sendLabel.backgroundColor = [UIColorclearColor];
//居中对齐
_sendLabel.textAlignment =NSTextAlignmentCenter;
//设置字体颜色
_sendLabel.textColor = [UIColorwhiteColor];
}
[selfaddSubview:_sendLabel];
_sendLabel.text = text;
//window设置为不隐藏
self.hidden =NO;
if(show) {
//显示window
//使用第三方框架AFNetworking中的"UIProgressView+AFNetworking"文件实现上传进度显示
[_progressViewsetProgressWithUploadProgressOfOperation:operationanimated:YES];
}else {
//延迟2秒,隐藏window
[selfperformSelector:@selector(hidden)withObject:nilafterDelay:2];
}
}
//隐藏
- (void)hidden
{
self.hidden =YES;
}
@end
在调用这个方法时,
- (void)showProgressView:(NSString *)text show:(BOOL)show operation:(AFHTTPRequestOperation *)operation;
然后
[statusWindowshowProgressView:@"正在发送"show:YESoperation:operation];
- 状态栏显示进度加载
- android状态栏显示进度
- 图片加载进度实时显示
- cocos2dx 资源加载进度显示
- 6.14--如何在状态栏内显示一个进度指示器?
- MFC在状态栏的窗格上显示进度栏
- [js效果] 图片加载进度实时显示
- js效果 图片加载进度实时显示
- flash加载外部图片进度显示
- bootloader中显示nk加载进度
- javascript使图片加载进度实时显示
- Android自定义标题栏:显示网页加载进度
- WebView加载进度Progress的显示
- Android自定义标题栏:显示网页加载进度
- 状态栏的编程(时间状态栏,进度状态栏)
- C#中的webBrowser控件加载网页时实现进度显示
- 多线程加载数据显示进度窗体的例子
- Android--自定义标题栏之显示网页加载进度
- 纯CSS绘制三角形(多个角度)
- 敏捷开发流程总结
- tomcat的启动时间
- extjs2.3 GridPanel样本
- ThoughtWorks(中国)程序员读书雷达
- 状态栏显示进度加载
- kylin jdbc中slf4j版本冲突问题
- win7 VMware CentOS桥接(bridge)模式网络配置
- <s:iterator>的status属性
- 开发笔记
- (乙)1003. 我要通过!
- smote算法
- 【绝对干货来啦】巧用jax-rs之jersey实现不确定数量、多类型文件批量一次上传接口
- android 设置系统的时间