over 9 years ago
1. Install pod " pod 'MBProgressHUD', '~> 0.9.1' " in your Xcode project
2. Once pods are installed successfully close your Xcode project & now open Xcode xcworkspace.
3. Now import mbprogress hud as #import "MBProgressHUD.h" in your desired View Controller.
4. Once imported succesfully create an object of MbProgress hud in your View Controller or utilities folder
as
- // SPINNER
- -(BOOL)showLoader
- {
- if (!spinner) {
- spinner = [[MBProgressHUD alloc]initWithView:self.view];
- }
- [self.view addSubview:spinner];
- [spinner show:YES];
- return YES;
- }
// SPINNER -(BOOL)showLoader { if (!spinner) { spinner = [[MBProgressHUD alloc]initWithView:self.view]; } [self.view addSubview:spinner]; [spinner show:YES]; return YES; }
5. Now you can use your Mbprogress hud in any ViewController you want,by simply importing #import "MBProgressHUD.h" & What's important is where to start spinner & where to stop.
6. Lets say you want to show spinner by the time u click Login Button & the stop spinner when it successfully Logs in.So all you have to do is call your loader/spinner/Mbprogress hud as
[self showLoader]; at the action of your Login button.
7. Now when you have performed Login Operation successfully to remove spinner simple call
8. [spinner show:YES] will remove your Mbprogress hud..thanks for reading.
0 Comment(s)