MBProgress的进度条

- (void)viewDidLoad {

[super viewDidLoad];

// Do any additional setup after loading the view, typically from a nib.

//显示

hud = [MBProgressHUD showHUDAddedTo:self.view animated:YES];

//设置提示模式

hud.mode = MBProgressHUDModeDeterminate;

//文字

hud.labelText = @"正在加载...";

//详情文字

//    hud.detailsLabelText = @"请稍后";

hud.animationType = MBProgressHUDAnimationZoomIn;

//当显示的时候执行某个方法

[hud showWhileExecuting:@selector(download:) onTarget:self withObject:hud animated:YES];

//隐藏指定视图上所有的hud

//    [MBProgressHUD hideAllHUDsForView:self.view animated:YES];

#if 1

//3秒后隐藏

[hud hide:YES afterDelay:100];

#endif

}

float progess;

//修改进度

- (void)download:(MBProgressHUD *)hud

{

NSLog(@"--- %d",[NSThread isMainThread]);

//分线程不能对UI进行操作

while (progess <= 1.0)

{

//线程休眠

sleep(1);

progess += 0.1;

//回调主线程

[self performSelectorOnMainThread:@selector(updateProgess:) withObject:@(progess) waitUntilDone:YES];

}

}

- (void)updateProgess:(NSNumber *)progess

{

//NSLog(@"&&&& %d",[NSThread isMainThread]);

NSLog(@"--- %f",[progess floatValue]);

hud.progress = [progess floatValue];

}

你可能感兴趣的:(MBProgress的进度条)