IOS _ 3rd library MBprogressHUD

Source: Internet
Author: User

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;




Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.