MBProgressHUDDemo

//

//  ZBMainViewController.m

//  MBProgressHUDDemo

//

//  Created by 张先森 on 14/11/27.

//  Copyright (c) 2014年 zhibin. All rights reserved.

//

#import "ZBMainViewController.h"

#import "MBProgressHUD+MJ.h"

@interface ZBMainViewController ()

{

MBProgressHUD *HUD;

}

- (IBAction)showTextDialog:(id)sender;

- (IBAction)showProgressOne:(id)sender;

- (IBAction)showProgressTwo:(id)sender;

- (IBAction)showProgressThree:(id)sender;

- (IBAction)showCustomDialog:(id)sender;

- (IBAction)showAllTextDialog:(id)sender;

@end

@implementation ZBMainViewController

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil

{

self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];

if (self) {

// Custom initialization

}

return self;

}

- (void)viewDidLoad

{

[super viewDidLoad];

// Do any additional setup after loading the view from its nib.

}

- (void)didReceiveMemoryWarning

{

[super didReceiveMemoryWarning];

// Dispose of any resources that can be recreated.

}

- (IBAction)showTextDialog:(id)sender {

HUD=[[MBProgressHUD alloc] initWithView:self.view];

[self.view addSubview:HUD];

HUD.dimBackground=YES;

[email protected]"请稍后";

[HUD showAnimated:YES whileExecutingBlock:^{

sleep(10);

} completionBlock:^{

[HUD removeFromSuperview];

}];

}

- (IBAction)showProgressOne:(id)sender {

HUD =[[MBProgressHUD alloc] initWithView:self.view];

[self.view addSubview:HUD];

HUD.mode=MBProgressHUDModeDeterminate;

[email protected]"请稍后";

[HUD showAnimated:YES whileExecutingBlock:^{

float progress = 0.0f;

while (progress < 1.0f) {

progress += 0.01f;

HUD.progress = progress;

usleep(10000);

}

} completionBlock:^{

[HUD removeFromSuperview];

HUD = nil;

}];

}

- (IBAction)showProgressTwo:(id)sender {

HUD=[[MBProgressHUD alloc] initWithView:self.view];

[self.view addSubview:HUD];

[email protected]"请稍后";

HUD.mode=MBProgressHUDModeAnnularDeterminate;

[HUD showAnimated:YES whileExecutingBlock:^{

float progress = 0.0f;

while (progress < 1.0f) {

progress += 0.01f;

HUD.progress = progress;

usleep(10000);

}

} completionBlock:^{

[HUD removeFromSuperview];

HUD = nil;

}];

}

- (IBAction)showProgressThree:(id)sender {

HUD=[[MBProgressHUD alloc] initWithView:self.view];

[self.view addSubview:HUD];

[email protected]"请稍后";

HUD.mode=MBProgressHUDModeDeterminateHorizontalBar;

[HUD showAnimated:YES whileExecutingBlock:^{

float progress = 0.0f;

while (progress < 1.0f) {

progress += 0.01f;

HUD.progress = progress;

usleep(10000);

}

} completionBlock:^{

[HUD removeFromSuperview];

HUD = nil;

}];

}

- (IBAction)showCustomDialog:(id)sender {

HUD=[[MBProgressHUD alloc] initWithView:self.view];

HUD.mode=MBProgressHUDModeCustomView;

HUD.customView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"tabbar_profile_selected_os7"]];

[self.view addSubview:HUD];

[email protected]"请稍后再试试";

[HUD showAnimated:YES whileExecutingBlock:^{

sleep(2);

} completionBlock:^{

[HUD removeFromSuperview];

HUD = nil;

}];

}

- (IBAction)showAllTextDialog:(id)sender {

HUD = [[MBProgressHUD alloc] initWithView:self.view];

[self.view addSubview:HUD];

HUD.labelText = @"操作成功";

HUD.mode = MBProgressHUDModeText;

//  HUD.customView = [[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"Checkmark"]] ];

[HUD showAnimated:YES whileExecutingBlock:^{

sleep(2);

} completionBlock:^{

[HUD removeFromSuperview];

HUD = nil;

}];

}

@end

时间: 2024-11-05 18:51:05

MBProgressHUDDemo的相关文章

MBProgressHUD 第三方库使用

关键操作:   效果如下:   ViewController.h 1 #import <UIKit/UIKit.h> 2 #import "MBProgressHUD.h" 3 4 @interface ViewController : UITableViewController<MBProgressHUDDelegate> 5 @property (strong, nonatomic) MBProgressHUD *hud; 6 @property (stro

iOS学习笔记--01swift实现提示框第三方库:MBProgressHUD

本文使用swift语言使用MBProgressHUD. 开源项目MBProgressHUD可以实现多种形式的提示框.使用简单,方便. GitHud的下载地址是:https://github.com/jdg/MBProgressHUD/ 下载完成后,将MBProgressHUD.h和MBProgressHUD.m拖入已经新建好的Swift项目.因为使用的swift语言,所以拖入项目的时候会提示是否新建一个桥接objective-c与swift的文件,选择是即可.此步骤会自动新建一个文件.如图: 在