IOS _ 3rd library MBprogressHUD
1. Add the downloaded 3rd-party library MBprogressHUD source code package to the project (which is actually a. h and. m file)
2. Go to Build Phases of the project and add all. m files in the source code package to the project.
3. Add the master header file "MBProgressHUD. h" of the 3rd-party class library"
Show Code:
// At the beginning of loading, a prompt message is displayed: MBProgressHUD * hud = [MBProgressHUD showHUDAddedTo: webView animated: YES]; // Add a mask hud. dimBackground = YES; hud. labelText = @ "loading the page... ";
Hide code:
// After loading, hide the prompt [MBProgressHUD hideAllHUDsForView: webView animated: YES];
Custom image display:
// Extracted, only for internal classification calling + (void) showMsg :( NSString *) msg imgName :( NSString *) imgName {// MBProgressHUD * hud = [MBProgressHUD showHUDAddedTo: [UIApplication sharedApplication]. keyWindow animated: YES]; // display mode, changed to customView, that is, display the custom image (mode setting, must be written before customView value assignment) hud. mode = MBProgressHUDModeCustomView; int delay = 1; if ([imgName is1_tostring: @ "error.png"]) {// when an error occurs, the system prompts 3 seconds of delay = 3 ;} imgName = [NSString stringWithFormat: @ "MBProgressHUD. bundle/% @ ", imgName]; // set the custom image hud to be displayed. customView = [[UIImageView alloc] initWithImage: [UIImage imageNamed: imgName]; // displayed text, for example, loading failed... loading... hud. labelText = msg; // flag: It must be YES to hide. When hidden, remove the hud from the parent control. removeFromSuperViewOnHide = YES; // automatically hide logs (@ "% d", delay) after 3 seconds; [hud hide: YES afterDelay: delay];}
Other common attributes
// The background color hud of the prompt box. color = [UIColor clearColor]; // This indicates no background. // The following text hud is displayed. detailsLabelText = @ "detail"; // shadow mask effect hud. dimBackground = YES; // hide [hud hide: YES afterDelay: 1] After 1 second; // only show the text hud. mode = MBProgressHUDModeText; // the margin and Y offset hud. margin = 0; hud. yOffset = 0; // hide and remove the hud from the parent control. removeFromSuperViewOnHide = YES; // circular progress bar hud. mode = MBProgressHUDModeAnnularDeterminate;