Third-party framework Mbprogresshud-----implement various prompt boxes

Source: Internet
Author: User
Tags usleep

The program runs as shown below:

Click the button to implement the corresponding prompt box:

Here only one of the pictures, interested can run the program yourself, see a few other tips box yo!!!

third-party framework Mbprogresshud:Https://github.com/jdg/MBProgressHUD

The program code is as follows:

//
Viewcontroller.m
Third-party framework--hint box
//
Created by Mac1 on 15/10/5.
Copyright (c) 2015 www.iphonetrain.com. All rights reserved.
//

#import "ViewController.h"
#import "MBProgressHUD.h"

@interface Viewcontroller ()
-(Ibaction) Textdialog: (ID) sender;
-(Ibaction) PROGRESSDIALOG1: (ID) sender;
-(Ibaction) PROGRESSDIALOG2: (ID) sender;
-(Ibaction) Customdialog: (ID) sender;
-(Ibaction) Alltextdialog: (ID) sender;

@end

@implementation Viewcontroller

-(void) Viewdidload {
[Super Viewdidload];


}

Text Prompt box
-(Ibaction) Textdialog: (ID) Sender {

Create a Progress box
__block Mbprogresshud *hud = [[Mbprogresshud Alloc]initwithview:self.view];
[Self.view Addsubview:hud];

Put the current view in the background
Hud.dimbackground = YES;

Set the text of the dialog box
Hud.labeltext = @ "Please wait a moment";

Show dialog box
[HUD Showanimated:yes whileexecutingblock:^{

What to do when the dialog box is displayed
Sleep (3);

} completionblock:^{
Actions that are performed after the operation is complete, suppress the dialog box
[HUD Removefromsuperview];
HUD = nil; Change object values in block, __block

}];
}

Progress Tip Box One
-(Ibaction) PROGRESSDIALOG1: (ID) Sender {

Create a Progress box
__block Mbprogresshud *hud = [[Mbprogresshud Alloc]initwithview:self.view];
[Self.view Addsubview:hud];

Hud.labeltext = @ "Loading";

Set Mode to Progress box
Hud.mode = mbprogresshudmodedeterminate;

Show Progress Box
[HUD Showanimated:yes whileexecutingblock:^{

Actions to perform when displayed

float progress = 0.0f;
while (Progress < 1.0f) {
Progress + = 0.01;
Hud.progress = progress;
Usleep (50000);

}
} completionblock:^{

Actions performed after completion
[HUD Removefromsuperview];
HUD = nil;

}];
}

Progress Prompt Box Two
-(Ibaction) PROGRESSDIALOG2: (ID) Sender {

Create a Progress box
__block Mbprogresshud *hud = [[Mbprogresshud Alloc]initwithview:self.view];
[Self.view Addsubview:hud];

Hud.labeltext = @ "Loading";

Set Mode to Progress box
Hud.mode = mbprogresshudmodeannulardeterminate;

Show Progress Box
[HUD Showanimated:yes whileexecutingblock:^{

Actions to perform when displayed

float progress = 0.0f;
while (Progress < 1.0f) {
Progress + = 0.01;
Hud.progress = progress;
Usleep (50000);

}
} completionblock:^{

Actions performed after completion
[HUD Removefromsuperview];
HUD = nil;

}];

}

Customizing the Progress Box
-(Ibaction) Customdialog: (ID) Sender {

Create a Progress box
__block Mbprogresshud *hud = [[Mbprogresshud Alloc]initwithview:self.view];
[Self.view Addsubview:hud];

Hud.labeltext = @ "Operation succeeded";
Hud.customview = [[Uiimageview alloc]initwithimage:[uiimage imagenamed:@ "Checkmark.png"]];
[HUD Showanimated:yes whileexecutingblock:^{

Sleep 2 seconds
Sleep (2);

} completionblock:^{

[HUD Removefromsuperview];
HUD = nil;

}];
}

Plain Text Prompt box
-(Ibaction) Alltextdialog: (ID) Sender {

Create a Progress box
__block Mbprogresshud *hud = [[Mbprogresshud Alloc]initwithview:self.view];
[Self.view Addsubview:hud];

Hud.labeltext = @ "You have operated on YO!!!";
Hud.mode = Mbprogresshudmodetext;

Specifies the offset of the displayed text, not specifying the default display in the middle of the screen

/*
Hud.xoffset = 150;
Hud.yoffset = 200;

*/
[HUD Showanimated:yes whileexecutingblock:^{

Sleep (3);

} completionblock:^{

[HUD Removefromsuperview];
HUD = nil;

}];
}
@end

Third-party framework Mbprogresshud-----implement various prompt boxes

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.