首页 > 代码库 > MBProgressHUDDemo

MBProgressHUDDemo

效果图:

工程图:

此代码需要加入第三方库MBProgressHUD

代码:

RootViewController.h

#import <UIKit/UIKit.h>//加入头文件#import "MBProgressHUD.h"@interface RootViewController : UIViewController<MBProgressHUDDelegate> {    MBProgressHUD *HUD;}@end

 

RootViewController.m

#import "RootViewController.h"//加入头文件#import <unistd.h>- (void)viewDidLoad{    [super viewDidLoad];    // Do any additional setup after loading the view.    //转动3s后停止    HUD = [[MBProgressHUD alloc] initWithView:self.navigationController.view];    HUD.delegate = self;    [HUD showWhileExecuting:@selector(myTask) onTarget:self withObject:nil animated:YES];    [self.navigationController.view addSubview:HUD];}//等待3s- (void)myTask {    sleep(3);}

 

MBProgressHUDDemo