Mbprogresshud is a third-party library in iOS that displays a loaded progress box or a prompt box on the interface, as shown in:
Here's a note on how to use Mbprogresshud:
1. Import Mbprogresshud into the project
Here we use Cocoapods Import, the contents of the Podfile file are as follows:
If you are not sure what the version of Mbprogresshud is, you can perform the pod Search Mbprogresshud command under Terminal to display the latest version of the current Mbprogresshud, as shown in:
2. Use Mbprogresshud in code
First declare a Mbprogresshud variable in the header file, need to introduce the corresponding header file, the code of the ViewController.h file is as follows:
#import "ViewController.h" @interface Viewcontroller () @end @implementation viewcontroller-(void) viewdidload { [ Super Viewdidload]; Initialize Mbprogresshud self.progresshud = [[Mbprogresshud alloc] initwithview:self.view];// Self.progressHUD.mode = mbprogresshudmodeindeterminate; self.progressHUD.progress = 0.4; Add Progresshud to the interface [Self.view AddSubview:self.progressHUD];} #pragma mark-Show Progress Box-(void) ShowProgress: (ID) Sender { self.progressHUD.dimBackground = NO;//Set Mask Self.progressHUD.labelText = @ "Loading ..."; Set the prompt text in the progress box [Self.progresshud show:yes];//Show Progress Box}-(void) didreceivememorywarning { [super Didreceivememorywarning]; Dispose of any resources the can be recreated.} @end
Among them, Mbprogresshud has some configuration items, which are explained below:
(1) Self.progressHUD.dimBackground configuration items. Whether the main configuration dialog has a matte, with a value of yes/no, the following two graphs are the differences between this configuration item:
(2) Self.progressHUD.mode configuration items. The configuration item has 6 different values, corresponding to 6 of the different shapes of the progress box, the value has the following 6 kinds:
typedef ns_enum (Nsinteger, Mbprogresshudmode) {/** Progress are shown using an Uiactivityindicatorview. This is the default. */mbprogresshudmodeindeterminate,/** Progress is shown using a round, pie-chart like, Progress view. */mbprogresshudmodedeterminate,/** Progress is shown using a horizontal Progress bar */ mbprogresshudmodedeterminatehorizontalbar,/** Progress is shown using a ring-shaped Progress view. */mbprogresshudmodeannulardeterminate,/** shows a custom view */mbprogresshudmodecustomview,/** Shows only Labels * * Mbprogresshudmodetext};
The corresponding progress box is as follows:
There is also a mode of Mbprogresshudmodecustomview, which is a custom view.
The Hide Progress box requires the following method to be called:
[Self.progresshud Hide:yes]; [Self.progresshud Hide:yes Afterdelay:5];
The first method is to hide the progress box immediately, and the second method is to delay 5 seconds before hiding the progress box.
3, Self.progressHUD.progress property. This property configures the progress shown in the Progress box with a value of 0-1
The use of iOS development Mbprogresshud