IOS asynchronous task progress loading prompt tool, ios progress loading
I. Introduction
DMProgressHUD is a View tool used to display the progress of Asynchronous Operation tasks. This tool contains the mainstream loading Status view types, which will be iterated in the future based on the actual situation or requirements. DMProgressHUD has five display modes at the design level:
Ii. Import (Platform: ios> = 8.0) solution 1: CocoaPods solution 2: direct import to project 3. Quick call
Note: use the default Style-Dark, Animation-gradient, and Mask-None for quick calls ).
1. Loading Mode1.1 Loading-Indicator
DMProgressHUD * hud = [DMProgressHUD showLoadingHUDAddedTo: self. view]; // hud. loadingType = DMProgressHUDLoadingTypeIndicator; // The default value is hud. text = @ "Here's info"; dispatch_async (dispatch_get_global_queue (queue, 0), ^ {// asynchronous time-consuming operation [self doSomething]; dispatch_async (dispatch_get_main_queue (), ^ {// The main return thread hides the HUD [hud dismiss] ;});
1.2 Loading-Circle
DMProgressHUD * hud = [DMProgressHUD showLoadingHUDAddedTo: self. view]; hud. loadingType = DMProgressHUDLoadingTypeCircle; hud. text = @ "Here's info"; dispatch_async (dispatch_get_global_queue (queue, 0), ^ {// asynchronous time-consuming operation [self doSomething]; dispatch_async (dispatch_get_main_queue (), ^ {// The main return thread hides the HUD [hud dismiss] ;});
2. Progress Mode2.1 Progress-Circle
DMProgressHUD * hud = [DMProgressHUD showProgressHUDAddedTo: self. view]; // hud. progressType = DMProgressHUDProgressTypeCircle; // The default value is hud. text = @ "Here's info"; dispatch_async (dispatch_get_global_queue (queue, 0), ^ {// asynchronous time-consuming operation [self doSomething]; dispatch_async (dispatch_get_main_queue (), ^ {// The main return thread hides the HUD [hud dismiss] ;});
2.2 Progress-Sector
DMProgressHUD * hud = [DMProgressHUD showProgressHUDAddedTo: self. view]; hud. progressType = DMProgressHUDProgressTypeSector; hud. text = @ "Here's info"; dispatch_async (dispatch_get_global_queue (queue, 0), ^ {// asynchronous time-consuming operation [self doSomething]; dispatch_async (dispatch_get_main_queue (), ^ {// The main return thread hides the HUD [hud dismiss] ;});
3. Status Mode3.1 Success
DMProgressHUD * hud = [DMProgressHUD showStatusHUDAddedTo: self. view statusType: DMProgressHUDStatusTypeSuccess]; hud. text = @ "Here's info"; dispatch_async (dispatch_get_global_queue (queue, 0), ^ {// asynchronous time-consuming operation [self doSomething]; dispatch_async (dispatch_get_main_queue (), ^ {// The main return thread hides the HUD [hud dismiss] ;});
3.2 Fail
DMProgressHUD * hud = [DMProgressHUD showStatusHUDAddedTo: self. view statusType: DMProgressHUDStatusTypeFail]; hud. text = @ "Here's info"; dispatch_async (dispatch_get_global_queue (queue, 0), ^ {// asynchronous time-consuming operation [self doSomething]; dispatch_async (dispatch_get_main_queue (), ^ {// The main return thread hides the HUD [hud dismiss] ;});
3.3 Warning
DMProgressHUD * hud = [DMProgressHUD showStatusHUDAddedTo: self. view statusType: DMProgressHUDStatusTypeWarning]; hud. text = @ "Here's info"; dispatch_async (dispatch_get_global_queue (queue, 0), ^ {// asynchronous time-consuming operation [self doSomething]; dispatch_async (dispatch_get_main_queue (), ^ {// The main return thread hides the HUD [hud dismiss] ;});
4. Text Mode4.1 Text
DMProgressHUD * hud = [DMProgressHUD showTextHUDAddedTo: self. view]; hud. text = @ "Here's info"; dispatch_async (dispatch_get_global_queue (queue, 0), ^ {// asynchronous time-consuming operation [self doSomething]; dispatch_async (dispatch_get_main_queue (), ^ {// The main return thread hides the HUD [hud dismiss] ;});
5. Custom Mode5.1 Custom
DMProgressHUD * hud = [DMProgressHUD showHUDAddedTo: self. view]; hud. mode = DMProgressHUDModeCustom; // specify the mode as the custom mode hud. text = @ "Here's info"; UIView * custom = [[UIImageView alloc] initWithImage: [UIImage imageNamed: @ "person"]; [hud setCustomView: custom width: 180.0 height: 180.0]; // custom View dispatch_async (dispatch_get_global_queue (queue, 0), ^ {// asynchronous time-consuming operation [self doSomething]; dispatch_async (dispatch_get_main_queue (), ^ {// The main return thread hides the HUD [hud dismiss] ;});
4. More
DMProgressHUDRun DemoView the effect. In addition, you canText spacing, color, etc.For customization, you canDMProgressHUD. hFile to view more API details.
More articles: simplified books
Contact info: damonmok1216@gmail.com.