├── .gitignore ├── .travis.yml ├── CHANGELOG.mdown ├── Demo ├── Classes │ ├── MBHudDemoAppDelegate.h │ ├── MBHudDemoAppDelegate.m │ ├── MBHudDemoViewController.h │ └── MBHudDemoViewController.m ├── HudDemo.xcodeproj │ ├── project.pbxproj │ ├── project.xcworkspace │ │ └── contents.xcworkspacedata │ └── xcshareddata │ │ └── xcschemes │ │ ├── HudDemo.xcscheme │ │ └── HudTests.xcscheme ├── HudDemo │ └── Images.xcassets │ │ ├── AppIcon.appiconset │ │ ├── Contents.json │ │ ├── Icon-167.png │ │ ├── Icon-60@2x.png │ │ ├── Icon-60@3x.png │ │ ├── Icon-72.png │ │ ├── Icon-72@2x.png │ │ ├── Icon-76.png │ │ ├── Icon-76@2x.png │ │ ├── Icon-Small-1.png │ │ ├── Icon-Small-40.png │ │ ├── Icon-Small-40@2x-1.png │ │ ├── Icon-Small-40@2x.png │ │ ├── Icon-Small-40@3x.png │ │ ├── Icon-Small-50.png │ │ ├── Icon-Small-50@2x.png │ │ ├── Icon-Small.png │ │ ├── Icon-Small@2x-1.png │ │ ├── Icon-Small@2x.png │ │ ├── Icon-Small@3x.png │ │ ├── Icon.png │ │ └── Icon@2x.png │ │ ├── Checkmark.imageset │ │ ├── Checkmark.png │ │ ├── Checkmark@2x.png │ │ ├── Checkmark@3x.png │ │ └── Contents.json │ │ └── Contents.json ├── HudDemo_Prefix.pch ├── HudTests │ ├── HudTests.m │ └── Info.plist ├── Info.plist ├── en.lproj │ ├── Launch.storyboard │ └── Main.storyboard └── main.m ├── Framework-Info.plist ├── LICENSE ├── MBProgressHUD-Prefix.pch ├── MBProgressHUD.h ├── MBProgressHUD.m ├── MBProgressHUD.podspec ├── MBProgressHUD.xcodeproj ├── project.pbxproj ├── project.xcworkspace │ └── contents.xcworkspacedata └── xcshareddata │ └── xcschemes │ ├── MBProgressHUD Framework.xcscheme │ └── MBProgressHUD.xcscheme ├── MBProgressHUD.xcworkspace └── contents.xcworkspacedata └── README.mdown /.gitignore: -------------------------------------------------------------------------------- 1 | # xcode noise 2 | build/ 3 | *.pbxuser 4 | *.mode1v3 5 | *.mode2v3 6 | *.perspectivev3 7 | xcuserdata/ 8 | *.xccheckout 9 | 10 | # old skool 11 | .svn 12 | 13 | # osx noise 14 | .DS_Store 15 | profile 16 | 17 | # vim noise 18 | *~ 19 | *.swp 20 | 21 | # AppCode noise 22 | .idea/ 23 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: objective-c 2 | osx_image: xcode7.2 3 | script: 4 | - xctool -workspace MBProgressHUD.xcworkspace -scheme HudTests -sdk iphonesimulator -destination "platform=iOS Simulator,name=iPad Air 2,OS=9.2" build test GCC_INSTRUMENT_PROGRAM_FLOW_ARCS=YES GCC_GENERATE_TEST_COVERAGE_FILES=YES 5 | after_success: 6 | - bash <(curl -s https://codecov.io/bash) 7 | -------------------------------------------------------------------------------- /CHANGELOG.mdown: -------------------------------------------------------------------------------- 1 | **Version 0.9.2** @ 22.12.15 2 | 3 | - Timer improvements 4 | - Additional assertions 5 | - Added a framework target 6 | - Tint progress tint color enhancements 7 | 8 | **Version 0.9.1** @ 06.03.15 9 | 10 | - Bug-fixes 11 | - Modernization 12 | 13 | **Version 0.9** @ 12.08.14 14 | 15 | - iOS 8 compatibility and some bug fixes. 16 | - Additional iOS 7 / iOS 8 styling enhancements. 17 | - Improved 64bit support. 18 | - Demo modernization. 19 | 20 | **Version 0.8** @ 19.09.13 21 | 22 | - iOS 7 compatibility and some bug fixes. 23 | 24 | **Version 0.7** @ 25.06.13 25 | 26 | - Added horizontal bar mode. ([jjxtra](https://github.com/jjxtra)). 27 | - CI integration. 28 | 29 | **Version 0.6** @ 13.03.13 30 | 31 | - Full cocoapods support. 32 | - Static library integration option. 33 | - Improved blocks support. 34 | - Bezel color. 35 | - Demo app fixes (iOS 6). 36 | - Various bug-fixes and enhancements. 37 | 38 | **Version 0.5** @ 22.03.12 39 | 40 | - Major source code modernization and cleanup (KVO, layout code, instance vars, etc.). 41 | - New annular determinate mode. 42 | - New text only mode. 43 | - Added a static library project and Xcode 4 workspace. 44 | - Added methods to find and return HUD(s) on a view. 45 | - Various bug fixes. 46 | - Various demo project enhancements (hi-res rescues, new samples). 47 | 48 | IMPORTANT: Requires LLVM 3+. 49 | 50 | **Version 0.41** @ 03.01.12 51 | 52 | - Support for ARC. 53 | 54 | **Version 0.4** @ 25.07.10 55 | 56 | - Different animation modes. Default set to zoom. 57 | - Class convenience methods ([tadelv](http://github.com/tadelv)). 58 | - Autorotation when added to a UIWindow ([wuf810](http://github.com/wuf810)). 59 | - Extended demo app. 60 | - Several smaller fixes. 61 | 62 | **Version 0.33** @ 27.03.10 63 | 64 | - Custom view operation mode added. 65 | - Fixed a memory leak. 66 | 67 | **Version 0.32** @ 4.01.10 68 | 69 | - Added minShowTime, graceTime, xOffset, yOffset. 70 | - Various fixes. 71 | 72 | **Version 0.31** @ 8.10.09 73 | 74 | - Fix for touch through during the fade-out animation. 75 | 76 | **Version 0.3** @ 30.9.09 77 | 78 | - Added show: and hide: methods. 79 | - Now using UIViews layoutSubviews to automate layout calls. 80 | - Added some floors to round pixel positions and thereby prevent unsharp views. 81 | - Some additional documentation and code cleanup. 82 | 83 | **Version 0.2** @ 21.7.09 84 | 85 | - Added determinate progress mode and switching capabilities between determinate and indeterminate modes. 86 | - Various bug-fixes. 87 | 88 | **Version 0.11** @ 2.6.09. 89 | 90 | - Updated labelText and detailsLabelText properties to support text modifications while the HUD is being shown. 91 | 92 | **Version 0.1** @ 2.4.09 93 | 94 | - Initial release. -------------------------------------------------------------------------------- /Demo/Classes/MBHudDemoAppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // MBHudDemoAppDelegate.h 3 | // HudDemo 4 | // 5 | // Created by Matej Bukovinski on 2.4.09. 6 | // Copyright bukovinski.com 2009-2015. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface MBHudDemoAppDelegate : NSObject 12 | 13 | @property (strong, nonatomic) UIWindow *window; 14 | 15 | @end 16 | -------------------------------------------------------------------------------- /Demo/Classes/MBHudDemoAppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // MBHudDemoAppDelegate.m 3 | // HudDemo 4 | // 5 | // Created by Matej Bukovinski on 2.4.09. 6 | // Copyright bukovinski.com 2009-2015. All rights reserved. 7 | // 8 | 9 | #import "MBHudDemoAppDelegate.h" 10 | #import "MBHudDemoViewController.h" 11 | 12 | 13 | @implementation MBHudDemoAppDelegate 14 | 15 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { 16 | self.window.tintColor = [UIColor colorWithRed:.337f green:.57f blue:.731f alpha:1.f]; 17 | return YES; 18 | } 19 | 20 | @end 21 | -------------------------------------------------------------------------------- /Demo/Classes/MBHudDemoViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // HudDemoViewController.h 3 | // HudDemo 4 | // 5 | // Created by Matej Bukovinski on 30.9.09. 6 | // Copyright bukovinski.com 2009-2015. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | 12 | @interface MBHudDemoViewController : UITableViewController 13 | 14 | @end 15 | -------------------------------------------------------------------------------- /Demo/Classes/MBHudDemoViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // MBHudDemoViewController.m 3 | // HudDemo 4 | // 5 | // Created by Matej Bukovinski on 30.9.09. 6 | // Copyright bukovinski.com 2009-2015. All rights reserved. 7 | // 8 | 9 | #import "MBHudDemoViewController.h" 10 | #import "MBProgressHUD.h" 11 | 12 | 13 | @interface MBExample : NSObject 14 | 15 | @property (nonatomic, copy) NSString *title; 16 | @property (nonatomic, assign) SEL selector; 17 | 18 | @end 19 | 20 | 21 | @implementation MBExample 22 | 23 | + (instancetype)exampleWithTitle:(NSString *)title selector:(SEL)selector { 24 | MBExample *example = [[self class] new]; 25 | example.title = title; 26 | example.selector = selector; 27 | return example; 28 | } 29 | 30 | @end 31 | 32 | 33 | @interface MBHudDemoViewController () 34 | 35 | @property (nonatomic, strong) NSArray *> *examples; 36 | @property (nonatomic, assign) BOOL canceled; 37 | 38 | @end 39 | 40 | 41 | @implementation MBHudDemoViewController 42 | 43 | #pragma mark - Lifecycle 44 | 45 | - (void)awakeFromNib { 46 | [super awakeFromNib]; 47 | self.examples = 48 | @[@[[MBExample exampleWithTitle:@"Indeterminate mode" selector:@selector(indeterminateExample)], 49 | [MBExample exampleWithTitle:@"With label" selector:@selector(labelExample)], 50 | [MBExample exampleWithTitle:@"With details label" selector:@selector(detailsLabelExample)]], 51 | @[[MBExample exampleWithTitle:@"Determinate mode" selector:@selector(determinateExample)], 52 | [MBExample exampleWithTitle:@"Annular determinate mode" selector:@selector(annularDeterminateExample)], 53 | [MBExample exampleWithTitle:@"Bar determinate mode" selector:@selector(barDeterminateExample)]], 54 | @[[MBExample exampleWithTitle:@"Text only" selector:@selector(textExample)], 55 | [MBExample exampleWithTitle:@"Custom view" selector:@selector(customViewExample)], 56 | [MBExample exampleWithTitle:@"With action button" selector:@selector(cancelationExample)], 57 | [MBExample exampleWithTitle:@"Mode switching" selector:@selector(modeSwitchingExample)]], 58 | @[[MBExample exampleWithTitle:@"On window" selector:@selector(indeterminateExample)], 59 | [MBExample exampleWithTitle:@"NSURLSession" selector:@selector(networkingExample)], 60 | [MBExample exampleWithTitle:@"Dim background" selector:@selector(indeterminateExample)], 61 | [MBExample exampleWithTitle:@"Colored" selector:@selector(indeterminateExample)]] 62 | ]; 63 | } 64 | 65 | #pragma mark - Examples 66 | 67 | - (void)indeterminateExample { 68 | // Show the HUD on the root view (self.view is a scrollable table view and thus not suitable, 69 | // as the HUD would move with the content as we scroll). 70 | MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:self.navigationController.view animated:YES]; 71 | 72 | // Fire off an asynchronous task, giving UIKit the opportunity to redraw wit the HUD added to the 73 | // view hierarchy. 74 | dispatch_async(dispatch_get_global_queue(QOS_CLASS_USER_INITIATED, 0), ^{ 75 | 76 | // Do something useful in the background 77 | [self doSomeWork]; 78 | 79 | // IMPORTANT - Dispatch back to the main thread. Always access UI 80 | // classes (including MBProgressHUD) on the main thread. 81 | dispatch_async(dispatch_get_main_queue(), ^{ 82 | [hud hideAnimated:YES]; 83 | }); 84 | }); 85 | } 86 | 87 | - (void)labelExample { 88 | MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:self.navigationController.view animated:YES]; 89 | 90 | // Set the label text. 91 | hud.label.text = NSLocalizedString(@"Loading...", @"HUD loading title"); 92 | // You can also adjust other label properties if needed. 93 | // hud.label.font = [UIFont italicSystemFontOfSize:16.f]; 94 | 95 | dispatch_async(dispatch_get_global_queue(QOS_CLASS_USER_INITIATED, 0), ^{ 96 | [self doSomeWork]; 97 | dispatch_async(dispatch_get_main_queue(), ^{ 98 | [hud hideAnimated:YES]; 99 | }); 100 | }); 101 | } 102 | 103 | - (void)detailsLabelExample { 104 | MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:self.navigationController.view animated:YES]; 105 | 106 | // Set the label text. 107 | hud.label.text = NSLocalizedString(@"Loading...", @"HUD loading title"); 108 | // Set the details label text. Let's make it multiline this time. 109 | hud.detailsLabel.text = NSLocalizedString(@"Parsing data\n(1/1)", @"HUD title"); 110 | 111 | dispatch_async(dispatch_get_global_queue(QOS_CLASS_USER_INITIATED, 0), ^{ 112 | [self doSomeWork]; 113 | dispatch_async(dispatch_get_main_queue(), ^{ 114 | [hud hideAnimated:YES]; 115 | }); 116 | }); 117 | } 118 | 119 | - (void)windowExample { 120 | // Covers the entire screen. Similar to using the root view controller view. 121 | MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:self.view.window animated:YES]; 122 | dispatch_async(dispatch_get_global_queue(QOS_CLASS_USER_INITIATED, 0), ^{ 123 | [self doSomeWork]; 124 | dispatch_async(dispatch_get_main_queue(), ^{ 125 | [hud hideAnimated:YES]; 126 | }); 127 | }); 128 | } 129 | 130 | - (void)determinateExample { 131 | MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:self.navigationController.view animated:YES]; 132 | 133 | // Set the determinate mode to show task progress. 134 | hud.mode = MBProgressHUDModeDeterminate; 135 | hud.label.text = NSLocalizedString(@"Loading...", @"HUD loading title"); 136 | 137 | dispatch_async(dispatch_get_global_queue(QOS_CLASS_USER_INITIATED, 0), ^{ 138 | // Do something useful in the background and update the HUD periodically. 139 | [self doSomeWorkWithProgress]; 140 | dispatch_async(dispatch_get_main_queue(), ^{ 141 | [hud hideAnimated:YES]; 142 | }); 143 | }); 144 | } 145 | 146 | - (void)annularDeterminateExample { 147 | MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:self.navigationController.view animated:YES]; 148 | 149 | // Set the annular determinate mode to show task progress. 150 | hud.mode = MBProgressHUDModeAnnularDeterminate; 151 | hud.label.text = NSLocalizedString(@"Loading...", @"HUD loading title"); 152 | 153 | dispatch_async(dispatch_get_global_queue(QOS_CLASS_USER_INITIATED, 0), ^{ 154 | // Do something useful in the background and update the HUD periodically. 155 | [self doSomeWorkWithProgress]; 156 | dispatch_async(dispatch_get_main_queue(), ^{ 157 | [hud hideAnimated:YES]; 158 | }); 159 | }); 160 | } 161 | 162 | - (void)barDeterminateExample { 163 | MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:self.navigationController.view animated:YES]; 164 | 165 | // Set the bar determinate mode to show task progress. 166 | hud.mode = MBProgressHUDModeDeterminateHorizontalBar; 167 | hud.label.text = NSLocalizedString(@"Loading...", @"HUD loading title"); 168 | 169 | dispatch_async(dispatch_get_global_queue(QOS_CLASS_USER_INITIATED, 0), ^{ 170 | // Do something useful in the background and update the HUD periodically. 171 | [self doSomeWorkWithProgress]; 172 | dispatch_async(dispatch_get_main_queue(), ^{ 173 | [hud hideAnimated:YES]; 174 | }); 175 | }); 176 | } 177 | 178 | - (void)customViewExample { 179 | MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:self.navigationController.view animated:YES]; 180 | 181 | // Set the custom view mode to show any view. 182 | hud.mode = MBProgressHUDModeCustomView; 183 | // Set an image view with a checkmark. 184 | UIImage *image = [[UIImage imageNamed:@"Checkmark"] imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate]; 185 | hud.customView = [[UIImageView alloc] initWithImage:image]; 186 | // Looks a bit nicer if we make it square. 187 | hud.square = YES; 188 | // Optional label text. 189 | hud.label.text = NSLocalizedString(@"Done", @"HUD done title"); 190 | 191 | [hud hideAnimated:YES afterDelay:3.f]; 192 | } 193 | 194 | - (void)textExample { 195 | MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:self.navigationController.view animated:YES]; 196 | 197 | // Set the annular determinate mode to show task progress. 198 | hud.mode = MBProgressHUDModeText; 199 | hud.label.text = NSLocalizedString(@"Message here!", @"HUD message title"); 200 | // Move to bottm center. 201 | hud.offset = CGPointMake(0.f, MBProgressMaxOffset); 202 | 203 | [hud hideAnimated:YES afterDelay:3.f]; 204 | } 205 | 206 | - (void)cancelationExample { 207 | MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:self.navigationController.view animated:YES]; 208 | 209 | // Set the determinate mode to show task progress. 210 | hud.mode = MBProgressHUDModeDeterminate; 211 | hud.label.text = NSLocalizedString(@"Loading...", @"HUD loading title"); 212 | 213 | // Configure the button. 214 | [hud.button setTitle:NSLocalizedString(@"Cancel", @"HUD cancel button title") forState:UIControlStateNormal]; 215 | [hud.button addTarget:self action:@selector(cancelWork:) forControlEvents:UIControlEventTouchUpInside]; 216 | 217 | dispatch_async(dispatch_get_global_queue(QOS_CLASS_USER_INITIATED, 0), ^{ 218 | // Do something useful in the background and update the HUD periodically. 219 | [self doSomeWorkWithProgress]; 220 | dispatch_async(dispatch_get_main_queue(), ^{ 221 | [hud hideAnimated:YES]; 222 | }); 223 | }); 224 | } 225 | 226 | - (void)modeSwitchingExample { 227 | MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:self.navigationController.view animated:YES]; 228 | 229 | // Set some text to show the initial status. 230 | hud.label.text = NSLocalizedString(@"Preparing...", @"HUD preparing title"); 231 | // Will look best, if we set a minimum size. 232 | hud.minSize = CGSizeMake(150.f, 100.f); 233 | 234 | dispatch_async(dispatch_get_global_queue(QOS_CLASS_USER_INITIATED, 0), ^{ 235 | // Do something useful in the background and update the HUD periodically. 236 | [self doSomeWorkWithMixedProgress]; 237 | dispatch_async(dispatch_get_main_queue(), ^{ 238 | [hud hideAnimated:YES]; 239 | }); 240 | }); 241 | } 242 | 243 | - (void)networkingExample { 244 | MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:self.navigationController.view animated:YES]; 245 | 246 | // Set some text to show the initial status. 247 | hud.label.text = NSLocalizedString(@"Preparing...", @"HUD preparing title"); 248 | // Will look best, if we set a minimum size. 249 | hud.minSize = CGSizeMake(150.f, 100.f); 250 | 251 | [self doSomeNetworkWorkWithProgress]; 252 | } 253 | 254 | #pragma mark - Tasks 255 | 256 | - (void)doSomeWork { 257 | // Simulate by just waiting. 258 | sleep(3.); 259 | } 260 | 261 | - (void)doSomeWorkWithProgress { 262 | self.canceled = NO; 263 | // This just increases the progress indicator in a loop. 264 | float progress = 0.0f; 265 | while (progress < 1.0f) { 266 | if (self.canceled) break; 267 | progress += 0.01f; 268 | dispatch_async(dispatch_get_main_queue(), ^{ 269 | // Instead we could have also passed a reference to the HUD 270 | // to the HUD to myProgressTask as a method parameter. 271 | [MBProgressHUD HUDForView:self.navigationController.view].progress = progress; 272 | }); 273 | usleep(50000); 274 | } 275 | } 276 | 277 | - (void)doSomeWorkWithMixedProgress { 278 | MBProgressHUD *hud = [MBProgressHUD HUDForView:self.navigationController.view]; 279 | // Indeterminate mode 280 | sleep(2); 281 | // Switch to determinate mode 282 | dispatch_async(dispatch_get_main_queue(), ^{ 283 | hud.mode = MBProgressHUDModeDeterminate; 284 | hud.label.text = NSLocalizedString(@"Loading...", @"HUD loading title"); 285 | }); 286 | float progress = 0.0f; 287 | while (progress < 1.0f) { 288 | progress += 0.01f; 289 | dispatch_async(dispatch_get_main_queue(), ^{ 290 | hud.progress = progress; 291 | }); 292 | usleep(50000); 293 | } 294 | // Back to indeterminate mode 295 | dispatch_async(dispatch_get_main_queue(), ^{ 296 | hud.mode = MBProgressHUDModeIndeterminate; 297 | hud.label.text = NSLocalizedString(@"Cleaning up...", @"HUD cleanining up title"); 298 | }); 299 | sleep(2); 300 | dispatch_sync(dispatch_get_main_queue(), ^{ 301 | UIImage *image = [[UIImage imageNamed:@"Checkmark"] imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate]; 302 | UIImageView *imageView = [[UIImageView alloc] initWithImage:image]; 303 | hud.customView = imageView; 304 | hud.mode = MBProgressHUDModeCustomView; 305 | hud.label.text = NSLocalizedString(@"Completed", @"HUD completed title"); 306 | }); 307 | sleep(2); 308 | } 309 | 310 | - (void)doSomeNetworkWorkWithProgress { 311 | NSURLSessionConfiguration *sessionConfig = [NSURLSessionConfiguration defaultSessionConfiguration]; 312 | NSURLSession *session = [NSURLSession sessionWithConfiguration:sessionConfig delegate:self delegateQueue:nil]; 313 | NSURL *URL = [NSURL URLWithString:@"https://support.apple.com/library/APPLE/APPLECARE_ALLGEOS/HT1425/sample_iPod.m4v.zip"]; 314 | NSURLSessionDownloadTask *task = [session downloadTaskWithURL:URL]; 315 | [task resume]; 316 | } 317 | 318 | - (void)cancelWork:(id)sender { 319 | self.canceled = YES; 320 | } 321 | 322 | #pragma mark - UITableViewDelegate 323 | 324 | - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { 325 | return self.examples.count; 326 | } 327 | 328 | - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { 329 | return self.examples[section].count; 330 | } 331 | 332 | - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { 333 | MBExample *example = self.examples[indexPath.section][indexPath.row]; 334 | UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"MBExampleCell" forIndexPath:indexPath]; 335 | cell.textLabel.text = example.title; 336 | cell.textLabel.textColor = self.view.tintColor; 337 | cell.textLabel.textAlignment = NSTextAlignmentCenter; 338 | cell.selectedBackgroundView = [UIView new]; 339 | cell.selectedBackgroundView.backgroundColor = [cell.textLabel.textColor colorWithAlphaComponent:0.1f]; 340 | return cell; 341 | } 342 | 343 | #pragma mark - UITableViewDelegate 344 | 345 | - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { 346 | MBExample *example = self.examples[indexPath.section][indexPath.row]; 347 | #pragma clang diagnostic push 348 | #pragma clang diagnostic ignored "-Warc-performSelector-leaks" 349 | [self performSelector:example.selector]; 350 | #pragma clang diagnostic pop 351 | 352 | dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ 353 | [tableView deselectRowAtIndexPath:indexPath animated:YES]; 354 | }); 355 | } 356 | 357 | #pragma mark - NSURLSessionDelegate 358 | 359 | - (void)URLSession:(NSURLSession *)session downloadTask:(NSURLSessionDownloadTask *)downloadTask didFinishDownloadingToURL:(NSURL *)location { 360 | // Do something with the data at location... 361 | 362 | // Update the UI on the main thread 363 | dispatch_async(dispatch_get_main_queue(), ^{ 364 | MBProgressHUD *hud = [MBProgressHUD HUDForView:self.navigationController.view]; 365 | UIImage *image = [[UIImage imageNamed:@"Checkmark"] imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate]; 366 | UIImageView *imageView = [[UIImageView alloc] initWithImage:image]; 367 | hud.customView = imageView; 368 | hud.mode = MBProgressHUDModeCustomView; 369 | hud.label.text = NSLocalizedString(@"Completed", @"HUD completed title"); 370 | [hud hideAnimated:YES afterDelay:3.f]; 371 | }); 372 | } 373 | 374 | - (void)URLSession:(NSURLSession *)session downloadTask:(NSURLSessionDownloadTask *)downloadTask didWriteData:(int64_t)bytesWritten totalBytesWritten:(int64_t)totalBytesWritten totalBytesExpectedToWrite:(int64_t)totalBytesExpectedToWrite { 375 | float progress = (float)totalBytesWritten / (float)totalBytesExpectedToWrite; 376 | 377 | // Update the UI on the main thread 378 | dispatch_async(dispatch_get_main_queue(), ^{ 379 | MBProgressHUD *hud = [MBProgressHUD HUDForView:self.navigationController.view]; 380 | hud.mode = MBProgressHUDModeDeterminate; 381 | hud.progress = progress; 382 | }); 383 | } 384 | 385 | @end 386 | -------------------------------------------------------------------------------- /Demo/HudDemo.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 1D3623260D0F684500981E51 /* MBHudDemoAppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 1D3623250D0F684500981E51 /* MBHudDemoAppDelegate.m */; }; 11 | 1D60589B0D05DD56006BFB54 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 29B97316FDCFA39411CA2CEA /* main.m */; }; 12 | 1D60589F0D05DD5A006BFB54 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1D30AB110D05D00D00671497 /* Foundation.framework */; }; 13 | 1DF5F4E00D08C38300B7A737 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1DF5F4DF0D08C38300B7A737 /* UIKit.framework */; }; 14 | 28D7ACF80DDB3853001CB0EB /* MBHudDemoViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 28D7ACF70DDB3853001CB0EB /* MBHudDemoViewController.m */; }; 15 | D22F7D810F85241C00550BB3 /* MBProgressHUD.m in Sources */ = {isa = PBXBuildFile; fileRef = D22F7D800F85241C00550BB3 /* MBProgressHUD.m */; }; 16 | D286A76D1518CA9F00E13FB8 /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D286A76C1518CA9F00E13FB8 /* CoreGraphics.framework */; }; 17 | D2B174121C5E3A3D00021915 /* HudTests.m in Sources */ = {isa = PBXBuildFile; fileRef = D2B174111C5E3A3D00021915 /* HudTests.m */; }; 18 | D2BC092F1BA587FB00589A7C /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = D2BC09311BA587FB00589A7C /* Main.storyboard */; }; 19 | D2EEB37B1B558F0900F59EC1 /* Launch.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = D2EEB3791B558F0900F59EC1 /* Launch.storyboard */; }; 20 | D2EEB3811B55967200F59EC1 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = D2EEB3801B55967200F59EC1 /* Images.xcassets */; }; 21 | /* End PBXBuildFile section */ 22 | 23 | /* Begin PBXContainerItemProxy section */ 24 | D2B174141C5E3A3D00021915 /* PBXContainerItemProxy */ = { 25 | isa = PBXContainerItemProxy; 26 | containerPortal = 29B97313FDCFA39411CA2CEA /* Project object */; 27 | proxyType = 1; 28 | remoteGlobalIDString = 1D6058900D05DD3D006BFB54; 29 | remoteInfo = HudDemo; 30 | }; 31 | /* End PBXContainerItemProxy section */ 32 | 33 | /* Begin PBXFileReference section */ 34 | 1D30AB110D05D00D00671497 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; 35 | 1D3623240D0F684500981E51 /* MBHudDemoAppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MBHudDemoAppDelegate.h; sourceTree = ""; }; 36 | 1D3623250D0F684500981E51 /* MBHudDemoAppDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MBHudDemoAppDelegate.m; sourceTree = ""; }; 37 | 1D6058910D05DD3D006BFB54 /* HudDemo.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = HudDemo.app; sourceTree = BUILT_PRODUCTS_DIR; }; 38 | 1DF5F4DF0D08C38300B7A737 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; }; 39 | 28D7ACF60DDB3853001CB0EB /* MBHudDemoViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MBHudDemoViewController.h; sourceTree = ""; }; 40 | 28D7ACF70DDB3853001CB0EB /* MBHudDemoViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MBHudDemoViewController.m; sourceTree = ""; usesTabs = 1; }; 41 | 29B97316FDCFA39411CA2CEA /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 42 | 32CA4F630368D1EE00C91783 /* HudDemo_Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HudDemo_Prefix.pch; sourceTree = ""; }; 43 | 8D1107310486CEB800E47090 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 44 | D22F7D7F0F85241C00550BB3 /* MBProgressHUD.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = MBProgressHUD.h; path = ../MBProgressHUD.h; sourceTree = SOURCE_ROOT; }; 45 | D22F7D800F85241C00550BB3 /* MBProgressHUD.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = MBProgressHUD.m; path = ../MBProgressHUD.m; sourceTree = ""; }; 46 | D286A76C1518CA9F00E13FB8 /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; }; 47 | D2B1740F1C5E3A3D00021915 /* HudTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = HudTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 48 | D2B174111C5E3A3D00021915 /* HudTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = HudTests.m; sourceTree = ""; }; 49 | D2B174131C5E3A3D00021915 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 50 | D2BC09301BA587FB00589A7C /* en */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = en; path = en.lproj/Main.storyboard; sourceTree = ""; }; 51 | D2EEB37A1B558F0900F59EC1 /* en */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = en; path = en.lproj/Launch.storyboard; sourceTree = ""; }; 52 | D2EEB3801B55967200F59EC1 /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; name = Images.xcassets; path = HudDemo/Images.xcassets; sourceTree = SOURCE_ROOT; }; 53 | /* End PBXFileReference section */ 54 | 55 | /* Begin PBXFrameworksBuildPhase section */ 56 | 1D60588F0D05DD3D006BFB54 /* Frameworks */ = { 57 | isa = PBXFrameworksBuildPhase; 58 | buildActionMask = 2147483647; 59 | files = ( 60 | D286A76D1518CA9F00E13FB8 /* CoreGraphics.framework in Frameworks */, 61 | 1D60589F0D05DD5A006BFB54 /* Foundation.framework in Frameworks */, 62 | 1DF5F4E00D08C38300B7A737 /* UIKit.framework in Frameworks */, 63 | ); 64 | runOnlyForDeploymentPostprocessing = 0; 65 | }; 66 | D2B1740C1C5E3A3D00021915 /* Frameworks */ = { 67 | isa = PBXFrameworksBuildPhase; 68 | buildActionMask = 2147483647; 69 | files = ( 70 | ); 71 | runOnlyForDeploymentPostprocessing = 0; 72 | }; 73 | /* End PBXFrameworksBuildPhase section */ 74 | 75 | /* Begin PBXGroup section */ 76 | 080E96DDFE201D6D7F000001 /* HudDemo */ = { 77 | isa = PBXGroup; 78 | children = ( 79 | 1D3623240D0F684500981E51 /* MBHudDemoAppDelegate.h */, 80 | 1D3623250D0F684500981E51 /* MBHudDemoAppDelegate.m */, 81 | 28D7ACF60DDB3853001CB0EB /* MBHudDemoViewController.h */, 82 | 28D7ACF70DDB3853001CB0EB /* MBHudDemoViewController.m */, 83 | 29B97315FDCFA39411CA2CEA /* Other Sources */, 84 | 29B97317FDCFA39411CA2CEA /* Resources */, 85 | ); 86 | name = HudDemo; 87 | path = Classes; 88 | sourceTree = ""; 89 | }; 90 | 19C28FACFE9D520D11CA2CBB /* Products */ = { 91 | isa = PBXGroup; 92 | children = ( 93 | 1D6058910D05DD3D006BFB54 /* HudDemo.app */, 94 | D2B1740F1C5E3A3D00021915 /* HudTests.xctest */, 95 | ); 96 | name = Products; 97 | sourceTree = ""; 98 | }; 99 | 29B97314FDCFA39411CA2CEA /* CustomTemplate */ = { 100 | isa = PBXGroup; 101 | children = ( 102 | 080E96DDFE201D6D7F000001 /* HudDemo */, 103 | D2B174101C5E3A3D00021915 /* HudTests */, 104 | D28CBB391A87A6B00052DCEC /* MBProgressHUD */, 105 | 29B97323FDCFA39411CA2CEA /* Frameworks */, 106 | 19C28FACFE9D520D11CA2CBB /* Products */, 107 | ); 108 | name = CustomTemplate; 109 | sourceTree = ""; 110 | }; 111 | 29B97315FDCFA39411CA2CEA /* Other Sources */ = { 112 | isa = PBXGroup; 113 | children = ( 114 | 32CA4F630368D1EE00C91783 /* HudDemo_Prefix.pch */, 115 | 29B97316FDCFA39411CA2CEA /* main.m */, 116 | ); 117 | name = "Other Sources"; 118 | path = ..; 119 | sourceTree = ""; 120 | }; 121 | 29B97317FDCFA39411CA2CEA /* Resources */ = { 122 | isa = PBXGroup; 123 | children = ( 124 | D277FDBF11FC880100304321 /* UI */, 125 | D2EEB3801B55967200F59EC1 /* Images.xcassets */, 126 | 8D1107310486CEB800E47090 /* Info.plist */, 127 | ); 128 | name = Resources; 129 | path = ..; 130 | sourceTree = ""; 131 | }; 132 | 29B97323FDCFA39411CA2CEA /* Frameworks */ = { 133 | isa = PBXGroup; 134 | children = ( 135 | D286A76C1518CA9F00E13FB8 /* CoreGraphics.framework */, 136 | 1DF5F4DF0D08C38300B7A737 /* UIKit.framework */, 137 | 1D30AB110D05D00D00671497 /* Foundation.framework */, 138 | ); 139 | name = Frameworks; 140 | sourceTree = ""; 141 | }; 142 | D277FDBF11FC880100304321 /* UI */ = { 143 | isa = PBXGroup; 144 | children = ( 145 | D2EEB3791B558F0900F59EC1 /* Launch.storyboard */, 146 | D2BC09311BA587FB00589A7C /* Main.storyboard */, 147 | ); 148 | name = UI; 149 | sourceTree = ""; 150 | }; 151 | D28CBB391A87A6B00052DCEC /* MBProgressHUD */ = { 152 | isa = PBXGroup; 153 | children = ( 154 | D22F7D7F0F85241C00550BB3 /* MBProgressHUD.h */, 155 | D22F7D800F85241C00550BB3 /* MBProgressHUD.m */, 156 | ); 157 | name = MBProgressHUD; 158 | sourceTree = ""; 159 | }; 160 | D2B174101C5E3A3D00021915 /* HudTests */ = { 161 | isa = PBXGroup; 162 | children = ( 163 | D2B174111C5E3A3D00021915 /* HudTests.m */, 164 | D2B174131C5E3A3D00021915 /* Info.plist */, 165 | ); 166 | path = HudTests; 167 | sourceTree = ""; 168 | }; 169 | /* End PBXGroup section */ 170 | 171 | /* Begin PBXNativeTarget section */ 172 | 1D6058900D05DD3D006BFB54 /* HudDemo */ = { 173 | isa = PBXNativeTarget; 174 | buildConfigurationList = 1D6058960D05DD3E006BFB54 /* Build configuration list for PBXNativeTarget "HudDemo" */; 175 | buildPhases = ( 176 | 1D60588D0D05DD3D006BFB54 /* Resources */, 177 | 1D60588E0D05DD3D006BFB54 /* Sources */, 178 | 1D60588F0D05DD3D006BFB54 /* Frameworks */, 179 | ); 180 | buildRules = ( 181 | ); 182 | dependencies = ( 183 | ); 184 | name = HudDemo; 185 | productName = HudDemo; 186 | productReference = 1D6058910D05DD3D006BFB54 /* HudDemo.app */; 187 | productType = "com.apple.product-type.application"; 188 | }; 189 | D2B1740E1C5E3A3D00021915 /* HudTests */ = { 190 | isa = PBXNativeTarget; 191 | buildConfigurationList = D2B174161C5E3A3D00021915 /* Build configuration list for PBXNativeTarget "HudTests" */; 192 | buildPhases = ( 193 | D2B1740B1C5E3A3D00021915 /* Sources */, 194 | D2B1740C1C5E3A3D00021915 /* Frameworks */, 195 | D2B1740D1C5E3A3D00021915 /* Resources */, 196 | ); 197 | buildRules = ( 198 | ); 199 | dependencies = ( 200 | D2B174151C5E3A3D00021915 /* PBXTargetDependency */, 201 | ); 202 | name = HudTests; 203 | productName = HudTests; 204 | productReference = D2B1740F1C5E3A3D00021915 /* HudTests.xctest */; 205 | productType = "com.apple.product-type.bundle.unit-test"; 206 | }; 207 | /* End PBXNativeTarget section */ 208 | 209 | /* Begin PBXProject section */ 210 | 29B97313FDCFA39411CA2CEA /* Project object */ = { 211 | isa = PBXProject; 212 | attributes = { 213 | CLASSPREFIX = MB; 214 | LastUpgradeCheck = 0720; 215 | ORGANIZATIONNAME = "Matej Bukovinski"; 216 | TargetAttributes = { 217 | D2B1740E1C5E3A3D00021915 = { 218 | CreatedOnToolsVersion = 7.2; 219 | TestTargetID = 1D6058900D05DD3D006BFB54; 220 | }; 221 | }; 222 | }; 223 | buildConfigurationList = C01FCF4E08A954540054247B /* Build configuration list for PBXProject "HudDemo" */; 224 | compatibilityVersion = "Xcode 3.2"; 225 | developmentRegion = English; 226 | hasScannedForEncodings = 1; 227 | knownRegions = ( 228 | English, 229 | Japanese, 230 | French, 231 | German, 232 | en, 233 | ); 234 | mainGroup = 29B97314FDCFA39411CA2CEA /* CustomTemplate */; 235 | projectDirPath = ""; 236 | projectRoot = ""; 237 | targets = ( 238 | 1D6058900D05DD3D006BFB54 /* HudDemo */, 239 | D2B1740E1C5E3A3D00021915 /* HudTests */, 240 | ); 241 | }; 242 | /* End PBXProject section */ 243 | 244 | /* Begin PBXResourcesBuildPhase section */ 245 | 1D60588D0D05DD3D006BFB54 /* Resources */ = { 246 | isa = PBXResourcesBuildPhase; 247 | buildActionMask = 2147483647; 248 | files = ( 249 | D2BC092F1BA587FB00589A7C /* Main.storyboard in Resources */, 250 | D2EEB3811B55967200F59EC1 /* Images.xcassets in Resources */, 251 | D2EEB37B1B558F0900F59EC1 /* Launch.storyboard in Resources */, 252 | ); 253 | runOnlyForDeploymentPostprocessing = 0; 254 | }; 255 | D2B1740D1C5E3A3D00021915 /* Resources */ = { 256 | isa = PBXResourcesBuildPhase; 257 | buildActionMask = 2147483647; 258 | files = ( 259 | ); 260 | runOnlyForDeploymentPostprocessing = 0; 261 | }; 262 | /* End PBXResourcesBuildPhase section */ 263 | 264 | /* Begin PBXSourcesBuildPhase section */ 265 | 1D60588E0D05DD3D006BFB54 /* Sources */ = { 266 | isa = PBXSourcesBuildPhase; 267 | buildActionMask = 2147483647; 268 | files = ( 269 | 1D60589B0D05DD56006BFB54 /* main.m in Sources */, 270 | 1D3623260D0F684500981E51 /* MBHudDemoAppDelegate.m in Sources */, 271 | 28D7ACF80DDB3853001CB0EB /* MBHudDemoViewController.m in Sources */, 272 | D22F7D810F85241C00550BB3 /* MBProgressHUD.m in Sources */, 273 | ); 274 | runOnlyForDeploymentPostprocessing = 0; 275 | }; 276 | D2B1740B1C5E3A3D00021915 /* Sources */ = { 277 | isa = PBXSourcesBuildPhase; 278 | buildActionMask = 2147483647; 279 | files = ( 280 | D2B174121C5E3A3D00021915 /* HudTests.m in Sources */, 281 | ); 282 | runOnlyForDeploymentPostprocessing = 0; 283 | }; 284 | /* End PBXSourcesBuildPhase section */ 285 | 286 | /* Begin PBXTargetDependency section */ 287 | D2B174151C5E3A3D00021915 /* PBXTargetDependency */ = { 288 | isa = PBXTargetDependency; 289 | target = 1D6058900D05DD3D006BFB54 /* HudDemo */; 290 | targetProxy = D2B174141C5E3A3D00021915 /* PBXContainerItemProxy */; 291 | }; 292 | /* End PBXTargetDependency section */ 293 | 294 | /* Begin PBXVariantGroup section */ 295 | D2BC09311BA587FB00589A7C /* Main.storyboard */ = { 296 | isa = PBXVariantGroup; 297 | children = ( 298 | D2BC09301BA587FB00589A7C /* en */, 299 | ); 300 | name = Main.storyboard; 301 | sourceTree = ""; 302 | }; 303 | D2EEB3791B558F0900F59EC1 /* Launch.storyboard */ = { 304 | isa = PBXVariantGroup; 305 | children = ( 306 | D2EEB37A1B558F0900F59EC1 /* en */, 307 | ); 308 | name = Launch.storyboard; 309 | sourceTree = ""; 310 | }; 311 | /* End PBXVariantGroup section */ 312 | 313 | /* Begin XCBuildConfiguration section */ 314 | 1D6058940D05DD3E006BFB54 /* Debug */ = { 315 | isa = XCBuildConfiguration; 316 | buildSettings = { 317 | ALWAYS_SEARCH_USER_PATHS = NO; 318 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 319 | COPY_PHASE_STRIP = NO; 320 | GCC_DYNAMIC_NO_PIC = NO; 321 | GCC_OPTIMIZATION_LEVEL = 0; 322 | GCC_PRECOMPILE_PREFIX_HEADER = YES; 323 | GCC_PREFIX_HEADER = HudDemo_Prefix.pch; 324 | INFOPLIST_FILE = Info.plist; 325 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 326 | PRODUCT_BUNDLE_IDENTIFIER = "com.bukovinski.${PRODUCT_NAME:identifier}"; 327 | PRODUCT_NAME = HudDemo; 328 | TARGETED_DEVICE_FAMILY = "1,2"; 329 | }; 330 | name = Debug; 331 | }; 332 | 1D6058950D05DD3E006BFB54 /* Release */ = { 333 | isa = XCBuildConfiguration; 334 | buildSettings = { 335 | ALWAYS_SEARCH_USER_PATHS = NO; 336 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 337 | COPY_PHASE_STRIP = YES; 338 | GCC_PRECOMPILE_PREFIX_HEADER = YES; 339 | GCC_PREFIX_HEADER = HudDemo_Prefix.pch; 340 | INFOPLIST_FILE = Info.plist; 341 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 342 | PRODUCT_BUNDLE_IDENTIFIER = "com.bukovinski.${PRODUCT_NAME:identifier}"; 343 | PRODUCT_NAME = HudDemo; 344 | SDKROOT = iphoneos; 345 | TARGETED_DEVICE_FAMILY = "1,2"; 346 | }; 347 | name = Release; 348 | }; 349 | C01FCF4F08A954540054247B /* Debug */ = { 350 | isa = XCBuildConfiguration; 351 | buildSettings = { 352 | CLANG_ENABLE_OBJC_ARC = YES; 353 | CLANG_WARN_BOOL_CONVERSION = YES; 354 | CLANG_WARN_CONSTANT_CONVERSION = YES; 355 | CLANG_WARN_EMPTY_BODY = YES; 356 | CLANG_WARN_ENUM_CONVERSION = YES; 357 | CLANG_WARN_INT_CONVERSION = YES; 358 | CLANG_WARN_UNREACHABLE_CODE = YES; 359 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 360 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 361 | ENABLE_STRICT_OBJC_MSGSEND = YES; 362 | ENABLE_TESTABILITY = YES; 363 | GCC_C_LANGUAGE_STANDARD = c99; 364 | GCC_NO_COMMON_BLOCKS = YES; 365 | GCC_VERSION = com.apple.compilers.llvm.clang.1_0; 366 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 367 | GCC_WARN_ABOUT_RETURN_TYPE = YES; 368 | GCC_WARN_UNDECLARED_SELECTOR = YES; 369 | GCC_WARN_UNINITIALIZED_AUTOS = YES; 370 | GCC_WARN_UNUSED_FUNCTION = YES; 371 | GCC_WARN_UNUSED_VARIABLE = YES; 372 | IPHONEOS_DEPLOYMENT_TARGET = 5.0; 373 | ONLY_ACTIVE_ARCH = YES; 374 | SDKROOT = iphoneos; 375 | }; 376 | name = Debug; 377 | }; 378 | C01FCF5008A954540054247B /* Release */ = { 379 | isa = XCBuildConfiguration; 380 | buildSettings = { 381 | CLANG_ENABLE_OBJC_ARC = YES; 382 | CLANG_WARN_BOOL_CONVERSION = YES; 383 | CLANG_WARN_CONSTANT_CONVERSION = YES; 384 | CLANG_WARN_EMPTY_BODY = YES; 385 | CLANG_WARN_ENUM_CONVERSION = YES; 386 | CLANG_WARN_INT_CONVERSION = YES; 387 | CLANG_WARN_UNREACHABLE_CODE = YES; 388 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 389 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 390 | ENABLE_STRICT_OBJC_MSGSEND = YES; 391 | GCC_C_LANGUAGE_STANDARD = c99; 392 | GCC_NO_COMMON_BLOCKS = YES; 393 | GCC_VERSION = com.apple.compilers.llvm.clang.1_0; 394 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 395 | GCC_WARN_ABOUT_RETURN_TYPE = YES; 396 | GCC_WARN_UNDECLARED_SELECTOR = YES; 397 | GCC_WARN_UNINITIALIZED_AUTOS = YES; 398 | GCC_WARN_UNUSED_FUNCTION = YES; 399 | GCC_WARN_UNUSED_VARIABLE = YES; 400 | IPHONEOS_DEPLOYMENT_TARGET = 5.0; 401 | SDKROOT = iphoneos; 402 | }; 403 | name = Release; 404 | }; 405 | D2B174171C5E3A3D00021915 /* Debug */ = { 406 | isa = XCBuildConfiguration; 407 | buildSettings = { 408 | ALWAYS_SEARCH_USER_PATHS = NO; 409 | BUNDLE_LOADER = "$(TEST_HOST)"; 410 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 411 | CLANG_CXX_LIBRARY = "libc++"; 412 | CLANG_ENABLE_MODULES = YES; 413 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 414 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 415 | COPY_PHASE_STRIP = NO; 416 | DEBUG_INFORMATION_FORMAT = dwarf; 417 | GCC_C_LANGUAGE_STANDARD = gnu99; 418 | GCC_DYNAMIC_NO_PIC = NO; 419 | GCC_OPTIMIZATION_LEVEL = 0; 420 | GCC_PREPROCESSOR_DEFINITIONS = ( 421 | "DEBUG=1", 422 | "$(inherited)", 423 | ); 424 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 425 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 426 | INFOPLIST_FILE = HudTests/Info.plist; 427 | IPHONEOS_DEPLOYMENT_TARGET = 9.2; 428 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 429 | MTL_ENABLE_DEBUG_INFO = YES; 430 | PRODUCT_BUNDLE_IDENTIFIER = com.bukovinski.HudTests; 431 | PRODUCT_NAME = "$(TARGET_NAME)"; 432 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/HudDemo.app/HudDemo"; 433 | }; 434 | name = Debug; 435 | }; 436 | D2B174181C5E3A3D00021915 /* Release */ = { 437 | isa = XCBuildConfiguration; 438 | buildSettings = { 439 | ALWAYS_SEARCH_USER_PATHS = NO; 440 | BUNDLE_LOADER = "$(TEST_HOST)"; 441 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 442 | CLANG_CXX_LIBRARY = "libc++"; 443 | CLANG_ENABLE_MODULES = YES; 444 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 445 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 446 | COPY_PHASE_STRIP = NO; 447 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 448 | ENABLE_NS_ASSERTIONS = NO; 449 | GCC_C_LANGUAGE_STANDARD = gnu99; 450 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 451 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 452 | INFOPLIST_FILE = HudTests/Info.plist; 453 | IPHONEOS_DEPLOYMENT_TARGET = 9.2; 454 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 455 | MTL_ENABLE_DEBUG_INFO = NO; 456 | PRODUCT_BUNDLE_IDENTIFIER = com.bukovinski.HudTests; 457 | PRODUCT_NAME = "$(TARGET_NAME)"; 458 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/HudDemo.app/HudDemo"; 459 | VALIDATE_PRODUCT = YES; 460 | }; 461 | name = Release; 462 | }; 463 | /* End XCBuildConfiguration section */ 464 | 465 | /* Begin XCConfigurationList section */ 466 | 1D6058960D05DD3E006BFB54 /* Build configuration list for PBXNativeTarget "HudDemo" */ = { 467 | isa = XCConfigurationList; 468 | buildConfigurations = ( 469 | 1D6058940D05DD3E006BFB54 /* Debug */, 470 | 1D6058950D05DD3E006BFB54 /* Release */, 471 | ); 472 | defaultConfigurationIsVisible = 0; 473 | defaultConfigurationName = Release; 474 | }; 475 | C01FCF4E08A954540054247B /* Build configuration list for PBXProject "HudDemo" */ = { 476 | isa = XCConfigurationList; 477 | buildConfigurations = ( 478 | C01FCF4F08A954540054247B /* Debug */, 479 | C01FCF5008A954540054247B /* Release */, 480 | ); 481 | defaultConfigurationIsVisible = 0; 482 | defaultConfigurationName = Release; 483 | }; 484 | D2B174161C5E3A3D00021915 /* Build configuration list for PBXNativeTarget "HudTests" */ = { 485 | isa = XCConfigurationList; 486 | buildConfigurations = ( 487 | D2B174171C5E3A3D00021915 /* Debug */, 488 | D2B174181C5E3A3D00021915 /* Release */, 489 | ); 490 | defaultConfigurationIsVisible = 0; 491 | }; 492 | /* End XCConfigurationList section */ 493 | }; 494 | rootObject = 29B97313FDCFA39411CA2CEA /* Project object */; 495 | } 496 | -------------------------------------------------------------------------------- /Demo/HudDemo.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /Demo/HudDemo.xcodeproj/xcshareddata/xcschemes/HudDemo.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 29 | 35 | 36 | 37 | 38 | 39 | 44 | 45 | 46 | 47 | 53 | 54 | 55 | 56 | 57 | 58 | 70 | 72 | 78 | 79 | 80 | 81 | 82 | 83 | 91 | 93 | 99 | 100 | 101 | 102 | 104 | 105 | 108 | 109 | 110 | -------------------------------------------------------------------------------- /Demo/HudDemo.xcodeproj/xcshareddata/xcschemes/HudTests.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 14 | 15 | 17 | 23 | 24 | 25 | 26 | 27 | 33 | 34 | 35 | 36 | 37 | 38 | 48 | 50 | 56 | 57 | 58 | 59 | 60 | 61 | 67 | 68 | 74 | 75 | 76 | 77 | 79 | 80 | 83 | 84 | 85 | -------------------------------------------------------------------------------- /Demo/HudDemo/Images.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "size" : "29x29", 5 | "idiom" : "iphone", 6 | "filename" : "Icon-Small.png", 7 | "scale" : "1x" 8 | }, 9 | { 10 | "size" : "29x29", 11 | "idiom" : "iphone", 12 | "filename" : "Icon-Small@2x.png", 13 | "scale" : "2x" 14 | }, 15 | { 16 | "size" : "29x29", 17 | "idiom" : "iphone", 18 | "filename" : "Icon-Small@3x.png", 19 | "scale" : "3x" 20 | }, 21 | { 22 | "size" : "40x40", 23 | "idiom" : "iphone", 24 | "filename" : "Icon-Small-40@2x.png", 25 | "scale" : "2x" 26 | }, 27 | { 28 | "size" : "40x40", 29 | "idiom" : "iphone", 30 | "filename" : "Icon-Small-40@3x.png", 31 | "scale" : "3x" 32 | }, 33 | { 34 | "size" : "57x57", 35 | "idiom" : "iphone", 36 | "filename" : "Icon.png", 37 | "scale" : "1x" 38 | }, 39 | { 40 | "size" : "57x57", 41 | "idiom" : "iphone", 42 | "filename" : "Icon@2x.png", 43 | "scale" : "2x" 44 | }, 45 | { 46 | "size" : "60x60", 47 | "idiom" : "iphone", 48 | "filename" : "Icon-60@2x.png", 49 | "scale" : "2x" 50 | }, 51 | { 52 | "size" : "60x60", 53 | "idiom" : "iphone", 54 | "filename" : "Icon-60@3x.png", 55 | "scale" : "3x" 56 | }, 57 | { 58 | "size" : "29x29", 59 | "idiom" : "ipad", 60 | "filename" : "Icon-Small-1.png", 61 | "scale" : "1x" 62 | }, 63 | { 64 | "size" : "29x29", 65 | "idiom" : "ipad", 66 | "filename" : "Icon-Small@2x-1.png", 67 | "scale" : "2x" 68 | }, 69 | { 70 | "size" : "40x40", 71 | "idiom" : "ipad", 72 | "filename" : "Icon-Small-40.png", 73 | "scale" : "1x" 74 | }, 75 | { 76 | "size" : "40x40", 77 | "idiom" : "ipad", 78 | "filename" : "Icon-Small-40@2x-1.png", 79 | "scale" : "2x" 80 | }, 81 | { 82 | "size" : "50x50", 83 | "idiom" : "ipad", 84 | "filename" : "Icon-Small-50.png", 85 | "scale" : "1x" 86 | }, 87 | { 88 | "size" : "50x50", 89 | "idiom" : "ipad", 90 | "filename" : "Icon-Small-50@2x.png", 91 | "scale" : "2x" 92 | }, 93 | { 94 | "size" : "72x72", 95 | "idiom" : "ipad", 96 | "filename" : "Icon-72.png", 97 | "scale" : "1x" 98 | }, 99 | { 100 | "size" : "72x72", 101 | "idiom" : "ipad", 102 | "filename" : "Icon-72@2x.png", 103 | "scale" : "2x" 104 | }, 105 | { 106 | "size" : "76x76", 107 | "idiom" : "ipad", 108 | "filename" : "Icon-76.png", 109 | "scale" : "1x" 110 | }, 111 | { 112 | "size" : "76x76", 113 | "idiom" : "ipad", 114 | "filename" : "Icon-76@2x.png", 115 | "scale" : "2x" 116 | }, 117 | { 118 | "size" : "83.5x83.5", 119 | "idiom" : "ipad", 120 | "filename" : "Icon-167.png", 121 | "scale" : "2x" 122 | } 123 | ], 124 | "info" : { 125 | "version" : 1, 126 | "author" : "xcode" 127 | } 128 | } -------------------------------------------------------------------------------- /Demo/HudDemo/Images.xcassets/AppIcon.appiconset/Icon-167.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IFTTT/MBProgressHUD/fbf05a09c283b283483eac7de4745639259b9219/Demo/HudDemo/Images.xcassets/AppIcon.appiconset/Icon-167.png -------------------------------------------------------------------------------- /Demo/HudDemo/Images.xcassets/AppIcon.appiconset/Icon-60@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IFTTT/MBProgressHUD/fbf05a09c283b283483eac7de4745639259b9219/Demo/HudDemo/Images.xcassets/AppIcon.appiconset/Icon-60@2x.png -------------------------------------------------------------------------------- /Demo/HudDemo/Images.xcassets/AppIcon.appiconset/Icon-60@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IFTTT/MBProgressHUD/fbf05a09c283b283483eac7de4745639259b9219/Demo/HudDemo/Images.xcassets/AppIcon.appiconset/Icon-60@3x.png -------------------------------------------------------------------------------- /Demo/HudDemo/Images.xcassets/AppIcon.appiconset/Icon-72.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IFTTT/MBProgressHUD/fbf05a09c283b283483eac7de4745639259b9219/Demo/HudDemo/Images.xcassets/AppIcon.appiconset/Icon-72.png -------------------------------------------------------------------------------- /Demo/HudDemo/Images.xcassets/AppIcon.appiconset/Icon-72@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IFTTT/MBProgressHUD/fbf05a09c283b283483eac7de4745639259b9219/Demo/HudDemo/Images.xcassets/AppIcon.appiconset/Icon-72@2x.png -------------------------------------------------------------------------------- /Demo/HudDemo/Images.xcassets/AppIcon.appiconset/Icon-76.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IFTTT/MBProgressHUD/fbf05a09c283b283483eac7de4745639259b9219/Demo/HudDemo/Images.xcassets/AppIcon.appiconset/Icon-76.png -------------------------------------------------------------------------------- /Demo/HudDemo/Images.xcassets/AppIcon.appiconset/Icon-76@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IFTTT/MBProgressHUD/fbf05a09c283b283483eac7de4745639259b9219/Demo/HudDemo/Images.xcassets/AppIcon.appiconset/Icon-76@2x.png -------------------------------------------------------------------------------- /Demo/HudDemo/Images.xcassets/AppIcon.appiconset/Icon-Small-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IFTTT/MBProgressHUD/fbf05a09c283b283483eac7de4745639259b9219/Demo/HudDemo/Images.xcassets/AppIcon.appiconset/Icon-Small-1.png -------------------------------------------------------------------------------- /Demo/HudDemo/Images.xcassets/AppIcon.appiconset/Icon-Small-40.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IFTTT/MBProgressHUD/fbf05a09c283b283483eac7de4745639259b9219/Demo/HudDemo/Images.xcassets/AppIcon.appiconset/Icon-Small-40.png -------------------------------------------------------------------------------- /Demo/HudDemo/Images.xcassets/AppIcon.appiconset/Icon-Small-40@2x-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IFTTT/MBProgressHUD/fbf05a09c283b283483eac7de4745639259b9219/Demo/HudDemo/Images.xcassets/AppIcon.appiconset/Icon-Small-40@2x-1.png -------------------------------------------------------------------------------- /Demo/HudDemo/Images.xcassets/AppIcon.appiconset/Icon-Small-40@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IFTTT/MBProgressHUD/fbf05a09c283b283483eac7de4745639259b9219/Demo/HudDemo/Images.xcassets/AppIcon.appiconset/Icon-Small-40@2x.png -------------------------------------------------------------------------------- /Demo/HudDemo/Images.xcassets/AppIcon.appiconset/Icon-Small-40@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IFTTT/MBProgressHUD/fbf05a09c283b283483eac7de4745639259b9219/Demo/HudDemo/Images.xcassets/AppIcon.appiconset/Icon-Small-40@3x.png -------------------------------------------------------------------------------- /Demo/HudDemo/Images.xcassets/AppIcon.appiconset/Icon-Small-50.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IFTTT/MBProgressHUD/fbf05a09c283b283483eac7de4745639259b9219/Demo/HudDemo/Images.xcassets/AppIcon.appiconset/Icon-Small-50.png -------------------------------------------------------------------------------- /Demo/HudDemo/Images.xcassets/AppIcon.appiconset/Icon-Small-50@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IFTTT/MBProgressHUD/fbf05a09c283b283483eac7de4745639259b9219/Demo/HudDemo/Images.xcassets/AppIcon.appiconset/Icon-Small-50@2x.png -------------------------------------------------------------------------------- /Demo/HudDemo/Images.xcassets/AppIcon.appiconset/Icon-Small.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IFTTT/MBProgressHUD/fbf05a09c283b283483eac7de4745639259b9219/Demo/HudDemo/Images.xcassets/AppIcon.appiconset/Icon-Small.png -------------------------------------------------------------------------------- /Demo/HudDemo/Images.xcassets/AppIcon.appiconset/Icon-Small@2x-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IFTTT/MBProgressHUD/fbf05a09c283b283483eac7de4745639259b9219/Demo/HudDemo/Images.xcassets/AppIcon.appiconset/Icon-Small@2x-1.png -------------------------------------------------------------------------------- /Demo/HudDemo/Images.xcassets/AppIcon.appiconset/Icon-Small@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IFTTT/MBProgressHUD/fbf05a09c283b283483eac7de4745639259b9219/Demo/HudDemo/Images.xcassets/AppIcon.appiconset/Icon-Small@2x.png -------------------------------------------------------------------------------- /Demo/HudDemo/Images.xcassets/AppIcon.appiconset/Icon-Small@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IFTTT/MBProgressHUD/fbf05a09c283b283483eac7de4745639259b9219/Demo/HudDemo/Images.xcassets/AppIcon.appiconset/Icon-Small@3x.png -------------------------------------------------------------------------------- /Demo/HudDemo/Images.xcassets/AppIcon.appiconset/Icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IFTTT/MBProgressHUD/fbf05a09c283b283483eac7de4745639259b9219/Demo/HudDemo/Images.xcassets/AppIcon.appiconset/Icon.png -------------------------------------------------------------------------------- /Demo/HudDemo/Images.xcassets/AppIcon.appiconset/Icon@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IFTTT/MBProgressHUD/fbf05a09c283b283483eac7de4745639259b9219/Demo/HudDemo/Images.xcassets/AppIcon.appiconset/Icon@2x.png -------------------------------------------------------------------------------- /Demo/HudDemo/Images.xcassets/Checkmark.imageset/Checkmark.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IFTTT/MBProgressHUD/fbf05a09c283b283483eac7de4745639259b9219/Demo/HudDemo/Images.xcassets/Checkmark.imageset/Checkmark.png -------------------------------------------------------------------------------- /Demo/HudDemo/Images.xcassets/Checkmark.imageset/Checkmark@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IFTTT/MBProgressHUD/fbf05a09c283b283483eac7de4745639259b9219/Demo/HudDemo/Images.xcassets/Checkmark.imageset/Checkmark@2x.png -------------------------------------------------------------------------------- /Demo/HudDemo/Images.xcassets/Checkmark.imageset/Checkmark@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IFTTT/MBProgressHUD/fbf05a09c283b283483eac7de4745639259b9219/Demo/HudDemo/Images.xcassets/Checkmark.imageset/Checkmark@3x.png -------------------------------------------------------------------------------- /Demo/HudDemo/Images.xcassets/Checkmark.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "Checkmark.png", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "filename" : "Checkmark@2x.png", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "idiom" : "universal", 15 | "filename" : "Checkmark@3x.png", 16 | "scale" : "3x" 17 | } 18 | ], 19 | "info" : { 20 | "version" : 1, 21 | "author" : "xcode" 22 | } 23 | } -------------------------------------------------------------------------------- /Demo/HudDemo/Images.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } -------------------------------------------------------------------------------- /Demo/HudDemo_Prefix.pch: -------------------------------------------------------------------------------- 1 | // 2 | // Prefix header for all source files of the 'HudDemo' target in the 'HudDemo' project 3 | // 4 | 5 | #ifdef __OBJC__ 6 | #import 7 | #import 8 | #endif 9 | -------------------------------------------------------------------------------- /Demo/HudTests/HudTests.m: -------------------------------------------------------------------------------- 1 | // 2 | // HudTests.m 3 | // HudTests 4 | // 5 | // Created by Matej Bukovinski on 31. 01. 16. 6 | // Copyright © 2016 Matej Bukovinski. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "MBProgressHUD.h" 11 | 12 | 13 | #define weakify(var) __weak typeof(var) weak_##var = var; 14 | 15 | #define strongify(var) \ 16 | _Pragma("clang diagnostic push") \ 17 | _Pragma("clang diagnostic ignored \"-Wshadow\"") \ 18 | __strong typeof(var) var = weak_##var; \ 19 | _Pragma("clang diagnostic pop") 20 | 21 | 22 | @interface HudTests : XCTestCase 23 | 24 | @property (nonatomic) XCTestExpectation *hideExpectation; 25 | @property (nonatomic, copy) dispatch_block_t hideChecks; 26 | 27 | @end 28 | 29 | 30 | @implementation HudTests 31 | 32 | - (void)setUp { 33 | [super setUp]; 34 | } 35 | 36 | - (void)tearDown { 37 | [super tearDown]; 38 | } 39 | 40 | #pragma mark - Convenience 41 | 42 | - (void)testNonAnimatedConvenienceHUDPresentation { 43 | UIViewController *rootViewController = UIApplication.sharedApplication.keyWindow.rootViewController; 44 | UIView *rootView = rootViewController.view; 45 | 46 | MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:rootView animated:NO]; 47 | 48 | XCTAssertNotNil(hud, @"A HUD should be created."); 49 | XCTAssertEqualObjects(hud.superview, rootView, @"The hood should be added to the view."); 50 | XCTAssertTrue(hud.removeFromSuperViewOnHide, @"removeFromSuperViewOnHide should be enabled"); 51 | XCTAssertEqual(hud.alpha, 1.f, @"The HUD should be visible."); 52 | XCTAssertFalse(hud.hidden, @"The HUD should be visible."); 53 | 54 | XCTAssertEqual(hud.bezelView.alpha, 1.f, @"The HUD should be visible."); 55 | XCTAssertFalse([hud.bezelView.layer.animationKeys containsObject:@"opacity"], @"The opacity should NOT be animated."); 56 | 57 | XCTAssertEqualObjects([MBProgressHUD HUDForView:rootView], hud, @"The HUD should be found via the convenience operation."); 58 | 59 | XCTAssertTrue([MBProgressHUD hideHUDForView:rootView animated:NO], @"The HUD should be found and removed."); 60 | 61 | XCTAssertFalse([rootView.subviews containsObject:hud], @"The HUD should no longer be part of the view hierarchy."); 62 | XCTAssertEqual(hud.alpha, 0.f, @"The hud should be faded out."); 63 | XCTAssertNil(hud.superview, @"The HUD should no longer be part of the view hierarchy."); 64 | 65 | XCTAssertFalse([MBProgressHUD hideHUDForView:rootView animated:NO], @"A subsequent HUD hide operation should fail."); 66 | } 67 | 68 | - (void)testAnimatedConvenienceHUDPresentation { 69 | UIViewController *rootViewController = UIApplication.sharedApplication.keyWindow.rootViewController; 70 | UIView *rootView = rootViewController.view; 71 | 72 | self.hideExpectation = [self expectationWithDescription:@"The hudWasHidden: delegate should have been called."]; 73 | 74 | MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:rootView animated:YES]; 75 | hud.delegate = self; 76 | 77 | XCTAssertNotNil(hud, @"A HUD should be created."); 78 | XCTAssertEqualObjects(hud.superview, rootView, @"The hood should be added to the view."); 79 | XCTAssertTrue(hud.removeFromSuperViewOnHide, @"removeFromSuperViewOnHide should be enabled"); 80 | XCTAssertEqual(hud.alpha, 1.f, @"The HUD should be visible."); 81 | XCTAssertFalse(hud.hidden, @"The HUD should be visible."); 82 | 83 | XCTAssertEqual(hud.bezelView.alpha, 1.f, @"The HUD should be visible."); 84 | XCTAssertTrue([hud.bezelView.layer.animationKeys containsObject:@"opacity"], @"The opacity should be animated."); 85 | 86 | XCTAssertEqualObjects([MBProgressHUD HUDForView:rootView], hud, @"The HUD should be found via the convenience operation."); 87 | 88 | XCTAssertTrue([MBProgressHUD hideHUDForView:rootView animated:YES], @"The HUD should be found and removed."); 89 | 90 | XCTAssertTrue([rootView.subviews containsObject:hud], @"The HUD should still be part of the view hierarchy."); 91 | XCTAssertEqual(hud.alpha, 1.f, @"The hud should still be visible."); 92 | XCTAssertEqualObjects(hud.superview, rootView, @"The hood should be added to the view."); 93 | 94 | weakify(self); 95 | self.hideChecks = ^{ 96 | strongify(self); 97 | XCTAssertFalse([rootView.subviews containsObject:hud], @"The HUD should no longer be part of the view hierarchy."); 98 | XCTAssertEqual(hud.alpha, 0.f, @"The hud should be faded out."); 99 | XCTAssertNil(hud.superview, @"The HUD should no longer be part of the view hierarchy."); 100 | 101 | XCTAssertFalse([MBProgressHUD hideHUDForView:rootView animated:YES], @"A subsequent HUD hide operation should fail."); 102 | }; 103 | 104 | [self waitForExpectationsWithTimeout:5. handler:nil]; 105 | } 106 | 107 | #pragma mark - MBProgressHUDDelegate 108 | 109 | - (void)hudWasHidden:(MBProgressHUD *)hud { 110 | if (self.hideChecks) self.hideChecks(); 111 | self.hideChecks = nil; 112 | 113 | [self.hideExpectation fulfill]; 114 | self.hideExpectation = nil; 115 | } 116 | 117 | @end 118 | -------------------------------------------------------------------------------- /Demo/HudTests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | 24 | 25 | -------------------------------------------------------------------------------- /Demo/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | English 7 | CFBundleDisplayName 8 | ${PRODUCT_NAME} 9 | CFBundleExecutable 10 | ${EXECUTABLE_NAME} 11 | CFBundleIcons 12 | 13 | CFBundleIcons~ipad 14 | 15 | CFBundleIdentifier 16 | $(PRODUCT_BUNDLE_IDENTIFIER) 17 | CFBundleInfoDictionaryVersion 18 | 6.0 19 | CFBundleName 20 | ${PRODUCT_NAME} 21 | CFBundlePackageType 22 | APPL 23 | CFBundleShortVersionString 24 | 1.0 25 | CFBundleSignature 26 | ???? 27 | CFBundleVersion 28 | 1.0 29 | LSRequiresIPhoneOS 30 | 31 | UILaunchImages 32 | 33 | 34 | UILaunchImageMinimumOSVersion 35 | 7.0 36 | UILaunchImageName 37 | Default-iOS7 38 | UILaunchImageOrientation 39 | Portrait 40 | UILaunchImageSize 41 | {320, 568} 42 | 43 | 44 | UILaunchImageMinimumOSVersion 45 | 7.0 46 | UILaunchImageName 47 | Default-iOS7 48 | UILaunchImageOrientation 49 | Portrait 50 | UILaunchImageSize 51 | {320, 480} 52 | 53 | 54 | UILaunchStoryboardName 55 | Launch 56 | UIMainStoryboardFile 57 | Main 58 | UISupportedInterfaceOrientations 59 | 60 | UIInterfaceOrientationPortrait 61 | UIInterfaceOrientationPortraitUpsideDown 62 | UIInterfaceOrientationLandscapeLeft 63 | UIInterfaceOrientationLandscapeRight 64 | 65 | 66 | 67 | -------------------------------------------------------------------------------- /Demo/en.lproj/Launch.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | -------------------------------------------------------------------------------- /Demo/en.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | -------------------------------------------------------------------------------- /Demo/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // HudDemo 4 | // 5 | // Created by Matej Bukovinski on 2.4.09. 6 | // Copyright bukovinski.com 2009-2015. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "MBHudDemoAppDelegate.h" 11 | 12 | int main(int argc, char *argv[]) { 13 | @autoreleasepool { 14 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([MBHudDemoAppDelegate class])); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /Framework-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | FMWK 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | $(CURRENT_PROJECT_VERSION) 23 | NSPrincipalClass 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2009-2015 Matej Bukovinski 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in 11 | all copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | THE SOFTWARE. -------------------------------------------------------------------------------- /MBProgressHUD-Prefix.pch: -------------------------------------------------------------------------------- 1 | // 2 | // Prefix header for all source files of the 'MBProgressHUD' target in the 'MBProgressHUD' project 3 | // 4 | 5 | #import 6 | 7 | #ifndef __IPHONE_3_0 8 | #warning "This project uses features only available in iOS SDK 3.0 and later." 9 | #endif 10 | 11 | #ifdef __OBJC__ 12 | #import 13 | #import 14 | #import 15 | #endif 16 | -------------------------------------------------------------------------------- /MBProgressHUD.h: -------------------------------------------------------------------------------- 1 | // 2 | // MBProgressHUD.h 3 | // Version 0.9.2 4 | // Created by Matej Bukovinski on 2.4.09. 5 | // 6 | 7 | // This code is distributed under the terms and conditions of the MIT license. 8 | 9 | // Copyright (c) 2009-2015 Matej Bukovinski 10 | // 11 | // Permission is hereby granted, free of charge, to any person obtaining a copy 12 | // of this software and associated documentation files (the "Software"), to deal 13 | // in the Software without restriction, including without limitation the rights 14 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 15 | // copies of the Software, and to permit persons to whom the Software is 16 | // furnished to do so, subject to the following conditions: 17 | // 18 | // The above copyright notice and this permission notice shall be included in 19 | // all copies or substantial portions of the Software. 20 | // 21 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 22 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 23 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 24 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 25 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 26 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 27 | // THE SOFTWARE. 28 | 29 | #import 30 | #import 31 | #import 32 | 33 | @class MBBackgroundView; 34 | @protocol MBProgressHUDDelegate; 35 | 36 | 37 | extern CGFloat const MBProgressMaxOffset; 38 | 39 | typedef NS_ENUM(NSInteger, MBProgressHUDMode) { 40 | /// UIActivityIndicatorView. 41 | MBProgressHUDModeIndeterminate, 42 | /// A round, pie-chart like, progress view. 43 | MBProgressHUDModeDeterminate, 44 | /// Horizontal progress bar. 45 | MBProgressHUDModeDeterminateHorizontalBar, 46 | /// Ring-shaped progress view. 47 | MBProgressHUDModeAnnularDeterminate, 48 | /// Shows a custom view. 49 | MBProgressHUDModeCustomView, 50 | /// Shows only labels. 51 | MBProgressHUDModeText 52 | }; 53 | 54 | typedef NS_ENUM(NSInteger, MBProgressHUDAnimation) { 55 | /// Opacity animation 56 | MBProgressHUDAnimationFade, 57 | /// Opacity + scale animation (zoom in when appearing zoom out when disappearing) 58 | MBProgressHUDAnimationZoom, 59 | /// Opacity + scale animation (zoom out style) 60 | MBProgressHUDAnimationZoomOut, 61 | /// Opacity + scale animation (zoom in style) 62 | MBProgressHUDAnimationZoomIn 63 | }; 64 | 65 | typedef NS_ENUM(NSInteger, MBProgressHUDBackgroundStyle) { 66 | /// Solid color background 67 | MBProgressHUDBackgroundStyleSolidColor, 68 | /// UIVisualEffectView or UIToolbar.layer background view 69 | MBProgressHUDBackgroundStyleBlur 70 | }; 71 | 72 | 73 | NS_ASSUME_NONNULL_BEGIN 74 | 75 | 76 | /** 77 | * Displays a simple HUD window containing a progress indicator and two optional labels for short messages. 78 | * 79 | * This is a simple drop-in class for displaying a progress HUD view similar to Apple's private UIProgressHUD class. 80 | * The MBProgressHUD window spans over the entire space given to it by the initWithFrame: constructor and catches all 81 | * user input on this region, thereby preventing the user operations on components below the view. 82 | * 83 | * @note To still allow touches to pass through the HUD, you can set hud.userInteractionEnabled = NO. 84 | * @attention MBProgressHUD is a UI class and should therefore only be accessed on the main thread. 85 | */ 86 | @interface MBProgressHUD : UIView 87 | 88 | /** 89 | * Creates a new HUD, adds it to provided view and shows it. The counterpart to this method is hideHUDForView:animated:. 90 | * 91 | * @note This method sets removeFromSuperViewOnHide. The HUD will automatically be removed from the view hierarchy when hidden. 92 | * 93 | * @param view The view that the HUD will be added to 94 | * @param animated If set to YES the HUD will appear using the current animationType. If set to NO the HUD will not use 95 | * animations while appearing. 96 | * @return A reference to the created HUD. 97 | * 98 | * @see hideHUDForView:animated: 99 | * @see animationType 100 | */ 101 | + (instancetype)showHUDAddedTo:(UIView *)view animated:(BOOL)animated; 102 | 103 | /// @name Showing and hiding 104 | 105 | /** 106 | * Finds the top-most HUD subview and hides it. The counterpart to this method is showHUDAddedTo:animated:. 107 | * 108 | * @note This method sets `removeFromSuperViewOnHide`. The HUD will automatically be removed from the view hierarchy when hidden. 109 | * 110 | * @param view The view that is going to be searched for a HUD subview. 111 | * @param animated If set to YES the HUD will disappear using the current animationType. If set to NO the HUD will not use 112 | * animations while disappearing. 113 | * @return YES if a HUD was found and removed, NO otherwise. 114 | * 115 | * @see showHUDAddedTo:animated: 116 | * @see animationType 117 | */ 118 | + (BOOL)hideHUDForView:(UIView *)view animated:(BOOL)animated; 119 | 120 | /** 121 | * Finds the top-most HUD subview and returns it. 122 | * 123 | * @param view The view that is going to be searched. 124 | * @return A reference to the last HUD subview discovered. 125 | */ 126 | + (nullable MBProgressHUD *)HUDForView:(UIView *)view; 127 | 128 | /** 129 | * A convenience constructor that initializes the HUD with the view's bounds. Calls the designated constructor with 130 | * view.bounds as the parameter 131 | * 132 | * @param view The view instance that will provide the bounds for the HUD. Should be the same instance as 133 | * the HUD's superview (i.e., the view that the HUD will be added to). 134 | */ 135 | - (instancetype)initWithView:(UIView *)view; 136 | 137 | /** 138 | * Displays the HUD. 139 | * 140 | * @note You need to make sure that the main thread completes its run loop soon after this method call so 141 | * the user interface can be updated. Call this method when your task is already set-up to be executed in a new thread 142 | * (e.g., when using something like NSOperation or calling an asynchronous call like NSURLRequest). 143 | * 144 | * @param animated If set to YES the HUD will appear using the current animationType. If set to NO the HUD will not use 145 | * animations while appearing. 146 | * 147 | * @see animationType 148 | */ 149 | - (void)showAnimated:(BOOL)animated; 150 | 151 | /** 152 | * Hides the HUD. This still calls the hudWasHidden: delegate. This is the counterpart of the show: method. Use it to 153 | * hide the HUD when your task completes. 154 | * 155 | * @param animated If set to YES the HUD will disappear using the current animationType. If set to NO the HUD will not use 156 | * animations while disappearing. 157 | * 158 | * @see animationType 159 | */ 160 | - (void)hideAnimated:(BOOL)animated; 161 | 162 | /** 163 | * Hides the HUD after a delay. This still calls the hudWasHidden: delegate. This is the counterpart of the show: method. Use it to 164 | * hide the HUD when your task completes. 165 | * 166 | * @param animated If set to YES the HUD will disappear using the current animationType. If set to NO the HUD will not use 167 | * animations while disappearing. 168 | * @param delay Delay in seconds until the HUD is hidden. 169 | * 170 | * @see animationType 171 | */ 172 | - (void)hideAnimated:(BOOL)animated afterDelay:(NSTimeInterval)delay; 173 | 174 | /** 175 | * The HUD delegate object. Receives HUD state notifications. 176 | */ 177 | @property (weak, nonatomic) id delegate; 178 | 179 | /* 180 | * Grace period is the time (in seconds) that the invoked method may be run without 181 | * showing the HUD. If the task finishes before the grace time runs out, the HUD will 182 | * not be shown at all. 183 | * This may be used to prevent HUD display for very short tasks. 184 | * Defaults to 0 (no grace time). 185 | */ 186 | @property (assign, nonatomic) NSTimeInterval graceTime; 187 | 188 | /** 189 | * The minimum time (in seconds) that the HUD is shown. 190 | * This avoids the problem of the HUD being shown and than instantly hidden. 191 | * Defaults to 0 (no minimum show time). 192 | */ 193 | @property (assign, nonatomic) NSTimeInterval minShowTime; 194 | 195 | /** 196 | * Removes the HUD from its parent view when hidden. 197 | * Defaults to NO. 198 | */ 199 | @property (assign, nonatomic) BOOL removeFromSuperViewOnHide; 200 | 201 | /// @name Appearance 202 | 203 | /** 204 | * MBProgressHUD operation mode. The default is MBProgressHUDModeIndeterminate. 205 | */ 206 | @property (assign, nonatomic) MBProgressHUDMode mode; 207 | 208 | /** 209 | * A color that gets forwarded to all labels and supported indicators. Also sets the tintColor 210 | * for custom views on iOS 7+. Set to nil to manage color individually. 211 | * Defaults to semi-translucent black on iOS 7 and later and white on earlier iOS versions. 212 | */ 213 | @property (strong, nonatomic, nullable) UIColor *contentColor UI_APPEARANCE_SELECTOR; 214 | 215 | /** 216 | * The animation type that should be used when the HUD is shown and hidden. 217 | */ 218 | @property (assign, nonatomic) MBProgressHUDAnimation animationType UI_APPEARANCE_SELECTOR; 219 | 220 | /** 221 | * The bezel offset relative to the center of the view. You can use MBProgressMaxOffset 222 | * and -MBProgressMaxOffset to move the HUD all the way to the screen edge in each direction. 223 | * E.g., CGPointMake(0.f, MBProgressMaxOffset) would position the HUD centered on the bottom edge. 224 | */ 225 | @property (assign, nonatomic) CGPoint offset UI_APPEARANCE_SELECTOR; 226 | 227 | /** 228 | * The amount of space between the HUD edge and the HUD elements (labels, indicators or custom views). 229 | * This also represents the minimum bezel distance to the edge of the HUD view. 230 | * Defaults to 20.f 231 | */ 232 | @property (assign, nonatomic) CGFloat margin UI_APPEARANCE_SELECTOR; 233 | 234 | /** 235 | * The minimum size of the HUD bezel. Defaults to CGSizeZero (no minimum size). 236 | */ 237 | @property (assign, nonatomic) CGSize minSize UI_APPEARANCE_SELECTOR; 238 | 239 | /** 240 | * Force the HUD dimensions to be equal if possible. 241 | */ 242 | @property (assign, nonatomic, getter = isSquare) BOOL square UI_APPEARANCE_SELECTOR; 243 | 244 | /** 245 | * When enabled, the bezel center gets slightly affected by the device accelerometer data. 246 | * Has no effect on iOS < 7.0. Defaults to YES. 247 | */ 248 | @property (assign, nonatomic, getter=areDefaultMotionEffectsEnabled) BOOL defaultMotionEffectsEnabled UI_APPEARANCE_SELECTOR; 249 | 250 | /// @name Progress 251 | 252 | /** 253 | * The progress of the progress indicator, from 0.0 to 1.0. Defaults to 0.0. 254 | */ 255 | @property (assign, nonatomic) float progress; 256 | 257 | /// @name Views 258 | 259 | /** 260 | * The view containing the labels and indicator (or customView). 261 | */ 262 | @property (strong, nonatomic, readonly) MBBackgroundView *bezelView; 263 | 264 | /** 265 | * View coving the entire HUD area, placed behind bezelView. 266 | */ 267 | @property (strong, nonatomic, readonly) MBBackgroundView *backgroundView; 268 | 269 | /** 270 | * The UIView (e.g., a UIImageView) to be shown when the HUD is in MBProgressHUDModeCustomView. 271 | * The view should implement intrinsicContentSize for proper sizing. For best results use approximately 37 by 37 pixel. 272 | */ 273 | @property (strong, nonatomic, nullable) UIView *customView; 274 | 275 | /** 276 | * A label that holds an optional short message to be displayed below the activity indicator. The HUD is automatically resized to fit 277 | * the entire text. 278 | */ 279 | @property (strong, nonatomic, readonly) UILabel *label; 280 | 281 | /** 282 | * A label that holds an optional details message displayed below the labelText message. The details text can span multiple lines. 283 | */ 284 | @property (strong, nonatomic, readonly) UILabel *detailsLabel; 285 | 286 | /** 287 | * A button that is placed below the labels. Visible only if a target / action is added. 288 | */ 289 | @property (strong, nonatomic, readonly) UIButton *button; 290 | 291 | @end 292 | 293 | 294 | @protocol MBProgressHUDDelegate 295 | 296 | @optional 297 | 298 | /** 299 | * Called after the HUD was fully hidden from the screen. 300 | */ 301 | - (void)hudWasHidden:(MBProgressHUD *)hud; 302 | 303 | @end 304 | 305 | 306 | /** 307 | * A progress view for showing definite progress by filling up a circle (pie chart). 308 | */ 309 | @interface MBRoundProgressView : UIView 310 | 311 | /** 312 | * Progress (0.0 to 1.0) 313 | */ 314 | @property (nonatomic, assign) float progress; 315 | 316 | /** 317 | * Indicator progress color. 318 | * Defaults to white [UIColor whiteColor] 319 | */ 320 | @property (nonatomic, strong) UIColor *progressTintColor; 321 | 322 | /** 323 | * Indicator background (non-progress) color. 324 | * Only applicable on iOS version older than iOS 7. 325 | * Defaults to translucent white (alpha 0.1) 326 | */ 327 | @property (nonatomic, strong) UIColor *backgroundTintColor; 328 | 329 | /* 330 | * Display mode - NO = round or YES = annular. De+faults to round. 331 | */ 332 | @property (nonatomic, assign, getter = isAnnular) BOOL annular; 333 | 334 | @end 335 | 336 | 337 | /** 338 | * A flat bar progress view. 339 | */ 340 | @interface MBBarProgressView : UIView 341 | 342 | /** 343 | * Progress (0.0 to 1.0) 344 | */ 345 | @property (nonatomic, assign) float progress; 346 | 347 | /** 348 | * Bar border line color. 349 | * Defaults to white [UIColor whiteColor]. 350 | */ 351 | @property (nonatomic, strong) UIColor *lineColor; 352 | 353 | /** 354 | * Bar background color. 355 | * Defaults to clear [UIColor clearColor]; 356 | */ 357 | @property (nonatomic, strong) UIColor *progressRemainingColor; 358 | 359 | /** 360 | * Bar progress color. 361 | * Defaults to white [UIColor whiteColor]. 362 | */ 363 | @property (nonatomic, strong) UIColor *progressColor; 364 | 365 | @end 366 | 367 | 368 | @interface MBBackgroundView : UIView 369 | 370 | /** 371 | * The background style. 372 | * Defaults to MBProgressHUDBackgroundStyleBlur on iOS 7 or later and MBProgressHUDBackgroundStyleSolidColor otherwise. 373 | * @note Due to iOS 7 not supporting UIVisualEffectView the blur effect differs slightly between iOS 7 and later versions. 374 | */ 375 | @property (nonatomic) MBProgressHUDBackgroundStyle style; 376 | 377 | /** 378 | * The background color or the blur tint color. 379 | * @note Due to iOS 7 not supporting UIVisualEffectView the blur effect differs slightly between iOS 7 and later versions. 380 | */ 381 | @property (nonatomic, strong) UIColor *color; 382 | 383 | @end 384 | 385 | @interface MBProgressHUD (Deprecated) 386 | 387 | + (NSArray *)allHUDsForView:(UIView *)view __attribute__((deprecated("Store references when using more than one HUD per view."))); 388 | + (NSUInteger)hideAllHUDsForView:(UIView *)view animated:(BOOL)animated __attribute__((deprecated("Store references when using more than one HUD per view."))); 389 | 390 | - (id)initWithWindow:(UIWindow *)window __attribute__((deprecated("Use initWithView: instead."))); 391 | 392 | - (void)show:(BOOL)animated __attribute__((deprecated("Use showAnimated: instead."))); 393 | - (void)hide:(BOOL)animated __attribute__((deprecated("Use hideAnimated: instead."))); 394 | - (void)hide:(BOOL)animated afterDelay:(NSTimeInterval)delay __attribute__((deprecated("Use hideAnimated:afterDelay: instead."))); 395 | 396 | typedef void (^MBProgressHUDCompletionBlock)(); 397 | 398 | - (void)showWhileExecuting:(SEL)method onTarget:(id)target withObject:(id)object animated:(BOOL)animated __attribute__((deprecated("Use GCD directly."))); 399 | - (void)showAnimated:(BOOL)animated whileExecutingBlock:(dispatch_block_t)block __attribute__((deprecated("Use GCD directly."))); 400 | - (void)showAnimated:(BOOL)animated whileExecutingBlock:(dispatch_block_t)block completionBlock:(nullable MBProgressHUDCompletionBlock)completion __attribute__((deprecated("Use GCD directly."))); 401 | - (void)showAnimated:(BOOL)animated whileExecutingBlock:(dispatch_block_t)block onQueue:(dispatch_queue_t)queue __attribute__((deprecated("Use GCD directly."))); 402 | - (void)showAnimated:(BOOL)animated whileExecutingBlock:(dispatch_block_t)block onQueue:(dispatch_queue_t)queue 403 | completionBlock:(nullable MBProgressHUDCompletionBlock)completion __attribute__((deprecated("Use GCD directly."))); 404 | @property (copy, nullable) MBProgressHUDCompletionBlock completionBlock __attribute__((deprecated("Use GCD directly."))); 405 | @property (assign) BOOL taskInProgress __attribute__((deprecated("No longer needed."))); 406 | 407 | @property (nonatomic, copy) NSString *labelText __attribute__((deprecated("Use label.text instead."))); 408 | @property (nonatomic, strong) UIFont *labelFont __attribute__((deprecated("Use label.font instead."))); 409 | @property (nonatomic, strong) UIColor *labelColor __attribute__((deprecated("Use label.textColor instead."))); 410 | @property (nonatomic, copy) NSString *detailsLabelText __attribute__((deprecated("Use detailsLabel.text instead."))); 411 | @property (nonatomic, strong) UIFont *detailsLabelFont __attribute__((deprecated("Use detailsLabel.font instead."))); 412 | @property (nonatomic, strong) UIColor *detailsLabelColor __attribute__((deprecated("Use detailsLabel.textColor instead."))); 413 | @property (assign, nonatomic) CGFloat opacity __attribute__((deprecated("Customize bezelView properties instead."))); 414 | @property (strong, nonatomic) UIColor *color __attribute__((deprecated("Customize the bezelView color instead."))); 415 | @property (assign, nonatomic) CGFloat xOffset __attribute__((deprecated("Set offset.x instead."))); 416 | @property (assign, nonatomic) CGFloat yOffset __attribute__((deprecated("Set offset.y instead."))); 417 | @property (assign, nonatomic) CGFloat cornerRadius __attribute__((deprecated("Set bezelView.layer.cornerRadius instead."))); 418 | @property (assign, nonatomic) BOOL dimBackground __attribute__((deprecated("Customize HUD background properties instead."))); 419 | @property (strong, nonatomic) UIColor *activityIndicatorColor __attribute__((deprecated("Use UIAppearance to customize UIActivityIndicatorView."))); 420 | @property (atomic, assign, readonly) CGSize size __attribute__((deprecated("Get the bezelView.frame.size instead."))); 421 | 422 | @end 423 | 424 | NS_ASSUME_NONNULL_END 425 | -------------------------------------------------------------------------------- /MBProgressHUD.m: -------------------------------------------------------------------------------- 1 | // 2 | // MBProgressHUD.m 3 | // Version 0.9.2 4 | // Created by Matej Bukovinski on 2.4.09. 5 | // 6 | 7 | #import "MBProgressHUD.h" 8 | #import 9 | 10 | 11 | #ifndef kCFCoreFoundationVersionNumber_iOS_7_0 12 | #define kCFCoreFoundationVersionNumber_iOS_7_0 847.20 13 | #endif 14 | 15 | #ifndef kCFCoreFoundationVersionNumber_iOS_8_0 16 | #define kCFCoreFoundationVersionNumber_iOS_8_0 1129.15 17 | #endif 18 | 19 | #define MBMainThreadAssert() NSAssert([NSThread isMainThread], @"MBProgressHUD needs to be accessed on the main thread."); 20 | 21 | CGFloat const MBProgressMaxOffset = 1000000.f; 22 | 23 | static const CGFloat MBDefaultPadding = 4.f; 24 | static const CGFloat MBDefaultLabelFontSize = 16.f; 25 | static const CGFloat MBDefaultDetailsLabelFontSize = 12.f; 26 | 27 | 28 | @interface MBProgressHUD () { 29 | // Depricated 30 | UIColor *_activityIndicatorColor; 31 | CGFloat _opacity; 32 | } 33 | 34 | @property (nonatomic, assign) BOOL useAnimation; 35 | @property (nonatomic, assign, getter=hasFinished) BOOL finished; 36 | @property (nonatomic, strong) UIView *indicator; 37 | @property (nonatomic, strong) NSTimer *graceTimer; 38 | @property (nonatomic, strong) NSTimer *minShowTimer; 39 | @property (nonatomic, strong) NSDate *showStarted; 40 | @property (nonatomic, strong) NSArray *paddingConstraints; 41 | @property (nonatomic, strong) NSArray *bezelConstraints; 42 | @property (nonatomic, strong) UIView *topSpacer; 43 | @property (nonatomic, strong) UIView *bottomSpacer; 44 | 45 | // Deprecated 46 | @property (copy, nullable) MBProgressHUDCompletionBlock completionBlock; 47 | @property (assign) BOOL taskInProgress; 48 | 49 | @end 50 | 51 | 52 | @interface MBProgressHUDRoundedButton : UIButton 53 | @end 54 | 55 | 56 | @implementation MBProgressHUD 57 | 58 | #pragma mark - Class methods 59 | 60 | + (instancetype)showHUDAddedTo:(UIView *)view animated:(BOOL)animated { 61 | MBProgressHUD *hud = [[self alloc] initWithView:view]; 62 | hud.removeFromSuperViewOnHide = YES; 63 | [view addSubview:hud]; 64 | [hud showAnimated:animated]; 65 | return hud; 66 | } 67 | 68 | + (BOOL)hideHUDForView:(UIView *)view animated:(BOOL)animated { 69 | MBProgressHUD *hud = [self HUDForView:view]; 70 | if (hud != nil) { 71 | hud.removeFromSuperViewOnHide = YES; 72 | [hud hideAnimated:animated]; 73 | return YES; 74 | } 75 | return NO; 76 | } 77 | 78 | + (MBProgressHUD *)HUDForView:(UIView *)view { 79 | NSEnumerator *subviewsEnum = [view.subviews reverseObjectEnumerator]; 80 | for (UIView *subview in subviewsEnum) { 81 | if ([subview isKindOfClass:self]) { 82 | return (MBProgressHUD *)subview; 83 | } 84 | } 85 | return nil; 86 | } 87 | 88 | #pragma mark - Lifecycle 89 | 90 | - (void)commonInit { 91 | // Set default values for properties 92 | _animationType = MBProgressHUDAnimationFade; 93 | _mode = MBProgressHUDModeIndeterminate; 94 | _margin = 20.0f; 95 | _opacity = 1.f; 96 | _defaultMotionEffectsEnabled = YES; 97 | 98 | // Default color, depending on the current iOS version 99 | BOOL isLegacy = kCFCoreFoundationVersionNumber < kCFCoreFoundationVersionNumber_iOS_7_0; 100 | _contentColor = isLegacy ? [UIColor whiteColor] : [UIColor colorWithWhite:0.f alpha:0.7f]; 101 | // Transparent background 102 | self.opaque = NO; 103 | self.backgroundColor = [UIColor clearColor]; 104 | // Make it invisible for now 105 | self.alpha = 0.0f; 106 | self.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight; 107 | self.layer.allowsGroupOpacity = NO; 108 | 109 | [self setupViews]; 110 | [self updateIndicators]; 111 | [self registerForNotifications]; 112 | } 113 | 114 | - (instancetype)initWithFrame:(CGRect)frame { 115 | if ((self = [super initWithFrame:frame])) { 116 | [self commonInit]; 117 | } 118 | return self; 119 | } 120 | 121 | - (instancetype)initWithCoder:(NSCoder *)aDecoder { 122 | if ((self = [super initWithCoder:aDecoder])) { 123 | [self commonInit]; 124 | } 125 | return self; 126 | } 127 | 128 | - (id)initWithView:(UIView *)view { 129 | NSAssert(view, @"View must not be nil."); 130 | return [self initWithFrame:view.bounds]; 131 | } 132 | 133 | - (void)dealloc { 134 | [self unregisterFromNotifications]; 135 | } 136 | 137 | #pragma mark - Show & hide 138 | 139 | - (void)showAnimated:(BOOL)animated { 140 | MBMainThreadAssert(); 141 | self.useAnimation = animated; 142 | self.finished = NO; 143 | // If the grace time is set postpone the HUD display 144 | if (self.graceTime > 0.0) { 145 | NSTimer *timer = [NSTimer timerWithTimeInterval:self.graceTime target:self selector:@selector(handleGraceTimer:) userInfo:nil repeats:NO]; 146 | [[NSRunLoop currentRunLoop] addTimer:timer forMode:NSRunLoopCommonModes]; 147 | self.graceTimer = timer; 148 | } 149 | // ... otherwise show the HUD imediately 150 | else { 151 | [self showUsingAnimation:self.useAnimation]; 152 | } 153 | } 154 | 155 | - (void)hideAnimated:(BOOL)animated { 156 | MBMainThreadAssert(); 157 | self.useAnimation = animated; 158 | self.finished = YES; 159 | // If the minShow time is set, calculate how long the hud was shown, 160 | // and pospone the hiding operation if necessary 161 | if (self.minShowTime > 0.0 && self.showStarted) { 162 | NSTimeInterval interv = [[NSDate date] timeIntervalSinceDate:self.showStarted]; 163 | if (interv < self.minShowTime) { 164 | NSTimer *timer = [NSTimer timerWithTimeInterval:(self.minShowTime - interv) target:self selector:@selector(handleMinShowTimer:) userInfo:nil repeats:NO]; 165 | [[NSRunLoop currentRunLoop] addTimer:timer forMode:NSRunLoopCommonModes]; 166 | self.minShowTimer = timer; 167 | return; 168 | } 169 | } 170 | // ... otherwise hide the HUD immediately 171 | [self hideUsingAnimation:self.useAnimation]; 172 | } 173 | 174 | - (void)hideAnimated:(BOOL)animated afterDelay:(NSTimeInterval)delay { 175 | [self performSelector:@selector(hideDelayed:) withObject:[NSNumber numberWithBool:animated] afterDelay:delay]; 176 | } 177 | 178 | - (void)hideDelayed:(NSNumber *)animated { 179 | [self hideAnimated:[animated boolValue]]; 180 | } 181 | 182 | #pragma mark - Timer callbacks 183 | 184 | - (void)handleGraceTimer:(NSTimer *)theTimer { 185 | // Show the HUD only if the task is still running 186 | if (!self.hasFinished) { 187 | [self showUsingAnimation:self.useAnimation]; 188 | } 189 | } 190 | 191 | - (void)handleMinShowTimer:(NSTimer *)theTimer { 192 | [self hideUsingAnimation:self.useAnimation]; 193 | } 194 | 195 | #pragma mark - View Hierrarchy 196 | 197 | - (void)didMoveToSuperview { 198 | [self updateForCurrentOrientationAnimated:NO]; 199 | } 200 | 201 | #pragma mark - Internal show & hide operations 202 | 203 | - (void)showUsingAnimation:(BOOL)animated { 204 | // Cancel any scheduled hideDelayed: calls 205 | [NSObject cancelPreviousPerformRequestsWithTarget:self]; 206 | 207 | self.showStarted = [NSDate date]; 208 | self.alpha = 1.f; 209 | 210 | if (animated) { 211 | [self animateIn:YES withType:self.animationType completion:NULL]; 212 | } else { 213 | #pragma clang diagnostic push 214 | #pragma clang diagnostic ignored "-Wdeprecated-declarations" 215 | self.bezelView.alpha = self.opacity; 216 | #pragma clang diagnostic pop 217 | self.backgroundView.alpha = 1.f; 218 | } 219 | } 220 | 221 | - (void)hideUsingAnimation:(BOOL)animated { 222 | if (animated && self.showStarted) { 223 | [self animateIn:NO withType:self.animationType completion:^(BOOL finished) { 224 | [self done]; 225 | }]; 226 | } else { 227 | self.bezelView.alpha = 0.f; 228 | self.backgroundView.alpha = 1.f; 229 | [self done]; 230 | } 231 | self.showStarted = nil; 232 | } 233 | 234 | - (void)animateIn:(BOOL)animatingIn withType:(MBProgressHUDAnimation)type completion:(void(^)(BOOL finished))completion { 235 | // Automatically determine the correct 236 | if (type == MBProgressHUDAnimationZoom) { 237 | type = animatingIn ? MBProgressHUDAnimationZoomIn : MBProgressHUDAnimationZoomOut; 238 | } 239 | 240 | CGAffineTransform small = CGAffineTransformMakeScale(0.5f, 0.5f); 241 | CGAffineTransform large = CGAffineTransformMakeScale(1.5f, 1.5f); 242 | 243 | // Set starting state 244 | UIView *bezelView = self.bezelView; 245 | if (animatingIn && bezelView.alpha == 0.f && type == MBProgressHUDAnimationZoomIn) { 246 | bezelView.transform = small; 247 | } else if (animatingIn && bezelView.alpha == 0.f && type == MBProgressHUDAnimationZoomOut) { 248 | bezelView.transform = large; 249 | } 250 | 251 | // Perform animations 252 | dispatch_block_t animations = ^{ 253 | if (animatingIn) { 254 | bezelView.transform = CGAffineTransformIdentity; 255 | } else if (!animatingIn && type == MBProgressHUDAnimationZoomIn) { 256 | bezelView.transform = large; 257 | } else if (!animatingIn && type == MBProgressHUDAnimationZoomOut) { 258 | bezelView.transform = small; 259 | } 260 | #pragma clang diagnostic push 261 | #pragma clang diagnostic ignored "-Wdeprecated-declarations" 262 | bezelView.alpha = animatingIn ? self.opacity : 0.f; 263 | #pragma clang diagnostic pop 264 | self.backgroundView.alpha = animatingIn ? 1.f : 0.f; 265 | }; 266 | 267 | // Spring animations are nicer, but only available on iOS 7+ 268 | #if __IPHONE_OS_VERSION_MAX_ALLOWED >= 70000 269 | if (kCFCoreFoundationVersionNumber >= kCFCoreFoundationVersionNumber_iOS_7_0) { 270 | [UIView animateWithDuration:0.3 delay:0. usingSpringWithDamping:1.f initialSpringVelocity:0.f options:UIViewAnimationOptionBeginFromCurrentState animations:animations completion:completion]; 271 | return; 272 | } 273 | #endif 274 | [UIView animateWithDuration:0.3 delay:0. options:UIViewAnimationOptionBeginFromCurrentState animations:animations completion:completion]; 275 | } 276 | 277 | - (void)done { 278 | [NSObject cancelPreviousPerformRequestsWithTarget:self]; 279 | self.alpha = 0.0f; 280 | if (self.removeFromSuperViewOnHide) { 281 | [self removeFromSuperview]; 282 | } 283 | if (self.completionBlock) { 284 | self.completionBlock(); 285 | self.completionBlock = NULL; 286 | } 287 | 288 | id delegate = self.delegate; 289 | if ([delegate respondsToSelector:@selector(hudWasHidden:)]) { 290 | [delegate performSelector:@selector(hudWasHidden:) withObject:self]; 291 | } 292 | } 293 | 294 | #pragma mark - UI 295 | 296 | - (void)setupViews { 297 | UIColor *defaultColor = self.contentColor; 298 | 299 | MBBackgroundView *backgroundView = [[MBBackgroundView alloc] initWithFrame:self.bounds]; 300 | backgroundView.style = MBProgressHUDBackgroundStyleSolidColor; 301 | backgroundView.backgroundColor = [UIColor clearColor]; 302 | backgroundView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight; 303 | backgroundView.alpha = 0.f; 304 | [self addSubview:backgroundView]; 305 | _backgroundView = backgroundView; 306 | 307 | MBBackgroundView *bezelView = [MBBackgroundView new]; 308 | bezelView.translatesAutoresizingMaskIntoConstraints = NO; 309 | bezelView.layer.cornerRadius = 5.f; 310 | bezelView.alpha = 0.f; 311 | [self addSubview:bezelView]; 312 | _bezelView = bezelView; 313 | [self updateBezelMotionEffects]; 314 | 315 | UILabel *label = [UILabel new]; 316 | label.adjustsFontSizeToFitWidth = NO; 317 | label.textAlignment = NSTextAlignmentCenter; 318 | label.textColor = defaultColor; 319 | label.font = [UIFont boldSystemFontOfSize:MBDefaultLabelFontSize];; 320 | _label = label; 321 | 322 | UILabel *detailsLabel = [UILabel new]; 323 | detailsLabel.adjustsFontSizeToFitWidth = NO; 324 | detailsLabel.textAlignment = NSTextAlignmentCenter; 325 | detailsLabel.textColor = defaultColor; 326 | detailsLabel.numberOfLines = 0; 327 | detailsLabel.font = [UIFont boldSystemFontOfSize:MBDefaultDetailsLabelFontSize]; 328 | _detailsLabel = detailsLabel; 329 | 330 | UIButton *button = [MBProgressHUDRoundedButton buttonWithType:UIButtonTypeCustom]; 331 | button.titleLabel.textAlignment = NSTextAlignmentCenter; 332 | button.titleLabel.font = [UIFont boldSystemFontOfSize:MBDefaultDetailsLabelFontSize]; 333 | [button setTitleColor:defaultColor forState:UIControlStateNormal]; 334 | _button = button; 335 | 336 | for (UIView *view in @[label, detailsLabel, button]) { 337 | view.translatesAutoresizingMaskIntoConstraints = NO; 338 | [view setContentCompressionResistancePriority:998.f forAxis:UILayoutConstraintAxisHorizontal]; 339 | [view setContentCompressionResistancePriority:998.f forAxis:UILayoutConstraintAxisVertical]; 340 | [bezelView addSubview:view]; 341 | } 342 | 343 | UIView *topSpacer = [UIView new]; 344 | topSpacer.translatesAutoresizingMaskIntoConstraints = NO; 345 | topSpacer.hidden = YES; 346 | [bezelView addSubview:topSpacer]; 347 | _topSpacer = topSpacer; 348 | 349 | UIView *bottomSpacer = [UIView new]; 350 | bottomSpacer.translatesAutoresizingMaskIntoConstraints = NO; 351 | bottomSpacer.hidden = YES; 352 | [bezelView addSubview:bottomSpacer]; 353 | _bottomSpacer = bottomSpacer; 354 | } 355 | 356 | - (void)updateIndicators { 357 | UIView *indicator = self.indicator; 358 | BOOL isActivityIndicator = [indicator isKindOfClass:[UIActivityIndicatorView class]]; 359 | BOOL isRoundIndicator = [indicator isKindOfClass:[MBRoundProgressView class]]; 360 | 361 | MBProgressHUDMode mode = self.mode; 362 | if (mode == MBProgressHUDModeIndeterminate) { 363 | if (!isActivityIndicator) { 364 | // Update to indeterminate indicator 365 | [indicator removeFromSuperview]; 366 | indicator = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge]; 367 | [(UIActivityIndicatorView *)indicator startAnimating]; 368 | [self.bezelView addSubview:indicator]; 369 | } 370 | } 371 | else if (mode == MBProgressHUDModeDeterminateHorizontalBar) { 372 | // Update to bar determinate indicator 373 | [indicator removeFromSuperview]; 374 | indicator = [[MBBarProgressView alloc] init]; 375 | [self.bezelView addSubview:indicator]; 376 | } 377 | else if (mode == MBProgressHUDModeDeterminate || mode == MBProgressHUDModeAnnularDeterminate) { 378 | if (!isRoundIndicator) { 379 | // Update to determinante indicator 380 | [indicator removeFromSuperview]; 381 | indicator = [[MBRoundProgressView alloc] init]; 382 | [self.bezelView addSubview:indicator]; 383 | } 384 | if (mode == MBProgressHUDModeAnnularDeterminate) { 385 | [(MBRoundProgressView *)indicator setAnnular:YES]; 386 | } 387 | } 388 | else if (mode == MBProgressHUDModeCustomView && self.customView != indicator) { 389 | // Update custom view indicator 390 | [indicator removeFromSuperview]; 391 | indicator = self.customView; 392 | [self.bezelView addSubview:indicator]; 393 | } 394 | else if (mode == MBProgressHUDModeText) { 395 | [indicator removeFromSuperview]; 396 | indicator = nil; 397 | } 398 | indicator.translatesAutoresizingMaskIntoConstraints = NO; 399 | self.indicator = indicator; 400 | 401 | if ([indicator respondsToSelector:@selector(setProgress:)]) { 402 | [(id)indicator setValue:@(self.progress) forKey:@"progress"]; 403 | } 404 | 405 | [indicator setContentCompressionResistancePriority:998.f forAxis:UILayoutConstraintAxisHorizontal]; 406 | [indicator setContentCompressionResistancePriority:998.f forAxis:UILayoutConstraintAxisVertical]; 407 | 408 | [self updateViewsForColor:self.contentColor]; 409 | [self setNeedsUpdateConstraints]; 410 | } 411 | 412 | - (void)updateViewsForColor:(UIColor *)color { 413 | if (!color) return; 414 | 415 | self.label.textColor = color; 416 | self.detailsLabel.textColor = color; 417 | [self.button setTitleColor:color forState:UIControlStateNormal]; 418 | 419 | #pragma clang diagnostic push 420 | #pragma clang diagnostic ignored "-Wdeprecated-declarations" 421 | if (self.activityIndicatorColor) { 422 | color = self.activityIndicatorColor; 423 | } 424 | #pragma clang diagnostic pop 425 | 426 | UIView *indicator = self.indicator; 427 | if ([indicator isKindOfClass:[UIActivityIndicatorView class]]) { 428 | ((UIActivityIndicatorView *)indicator).color = color; 429 | } else if ([indicator isKindOfClass:[MBRoundProgressView class]]) { 430 | ((MBRoundProgressView *)indicator).progressTintColor = color; 431 | ((MBRoundProgressView *)indicator).backgroundTintColor = [color colorWithAlphaComponent:0.1]; 432 | } else if ([indicator isKindOfClass:[MBBarProgressView class]]) { 433 | ((MBBarProgressView *)indicator).progressColor = color; 434 | ((MBBarProgressView *)indicator).lineColor = color; 435 | } else { 436 | #if __IPHONE_OS_VERSION_MAX_ALLOWED >= 70000 437 | if ([indicator respondsToSelector:@selector(setTintColor:)]) { 438 | [indicator setTintColor:color]; 439 | } 440 | #endif 441 | } 442 | } 443 | 444 | - (void)updateBezelMotionEffects { 445 | #if __IPHONE_OS_VERSION_MAX_ALLOWED >= 70000 446 | MBBackgroundView *bezelView = self.bezelView; 447 | if (![bezelView respondsToSelector:@selector(addMotionEffect:)]) return; 448 | 449 | if (self.defaultMotionEffectsEnabled) { 450 | CGFloat effectOffset = 10.f; 451 | UIInterpolatingMotionEffect *effectX = [[UIInterpolatingMotionEffect alloc] initWithKeyPath:@"center.x" type:UIInterpolatingMotionEffectTypeTiltAlongHorizontalAxis]; 452 | effectX.maximumRelativeValue = @(effectOffset); 453 | effectX.minimumRelativeValue = @(-effectOffset); 454 | 455 | UIInterpolatingMotionEffect *effectY = [[UIInterpolatingMotionEffect alloc] initWithKeyPath:@"center.y" type:UIInterpolatingMotionEffectTypeTiltAlongVerticalAxis]; 456 | effectY.maximumRelativeValue = @(effectOffset); 457 | effectY.minimumRelativeValue = @(-effectOffset); 458 | 459 | UIMotionEffectGroup *group = [[UIMotionEffectGroup alloc] init]; 460 | group.motionEffects = @[effectX, effectY]; 461 | 462 | [bezelView addMotionEffect:group]; 463 | } else { 464 | NSArray *effects = [bezelView motionEffects]; 465 | for (UIMotionEffect *effect in effects) { 466 | [bezelView removeMotionEffect:effect]; 467 | } 468 | } 469 | #endif 470 | } 471 | 472 | #pragma mark - Layout 473 | 474 | - (void)updateConstraints { 475 | UIView *bezel = self.bezelView; 476 | UIView *topSpacer = self.topSpacer; 477 | UIView *bottomSpacer = self.bottomSpacer; 478 | CGFloat margin = self.margin; 479 | NSMutableArray *bezelConstraints = [NSMutableArray array]; 480 | NSDictionary *metrics = @{@"margin": @(margin)}; 481 | 482 | NSMutableArray *subviews = [NSMutableArray arrayWithObjects:self.topSpacer, self.label, self.detailsLabel, self.button, self.bottomSpacer, nil]; 483 | if (self.indicator) [subviews insertObject:self.indicator atIndex:1]; 484 | 485 | // Remove existing constraintes 486 | [self removeConstraints:self.constraints]; 487 | [topSpacer removeConstraints:topSpacer.constraints]; 488 | [bottomSpacer removeConstraints:bottomSpacer.constraints]; 489 | if (self.bezelConstraints) { 490 | [bezel removeConstraints:self.bezelConstraints]; 491 | self.bezelConstraints = nil; 492 | } 493 | 494 | // Center bezel in container (self), applying the offset if set 495 | CGPoint offset = self.offset; 496 | NSMutableArray *centeringConstraints = [NSMutableArray array]; 497 | [centeringConstraints addObject:[NSLayoutConstraint constraintWithItem:bezel attribute:NSLayoutAttributeCenterX relatedBy:NSLayoutRelationEqual toItem:self attribute:NSLayoutAttributeCenterX multiplier:1.f constant:offset.x]]; 498 | [centeringConstraints addObject:[NSLayoutConstraint constraintWithItem:bezel attribute:NSLayoutAttributeCenterY relatedBy:NSLayoutRelationEqual toItem:self attribute:NSLayoutAttributeCenterY multiplier:1.f constant:offset.y]]; 499 | [self applyPriority:998.f toConstraints:centeringConstraints]; 500 | [self addConstraints:centeringConstraints]; 501 | 502 | // Ensure minimum side margin is kept 503 | NSMutableArray *sideConstraints = [NSMutableArray array]; 504 | [sideConstraints addObjectsFromArray:[NSLayoutConstraint constraintsWithVisualFormat:@"|-(>=margin)-[bezel]-(>=margin)-|" options:0 metrics:metrics views:NSDictionaryOfVariableBindings(bezel)]]; 505 | [sideConstraints addObjectsFromArray:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|-(>=margin)-[bezel]-(>=margin)-|" options:0 metrics:metrics views:NSDictionaryOfVariableBindings(bezel)]]; 506 | [self applyPriority:999.f toConstraints:sideConstraints]; 507 | [self addConstraints:sideConstraints]; 508 | 509 | // Minimum bezel size, if set 510 | CGSize minimumSize = self.minSize; 511 | if (!CGSizeEqualToSize(minimumSize, CGSizeZero)) { 512 | NSMutableArray *minSizeConstraints = [NSMutableArray array]; 513 | [minSizeConstraints addObject:[NSLayoutConstraint constraintWithItem:bezel attribute:NSLayoutAttributeWidth relatedBy:NSLayoutRelationGreaterThanOrEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.f constant:minimumSize.width]]; 514 | [minSizeConstraints addObject:[NSLayoutConstraint constraintWithItem:bezel attribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationGreaterThanOrEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.f constant:minimumSize.height]]; 515 | [self applyPriority:997.f toConstraints:minSizeConstraints]; 516 | [bezelConstraints addObjectsFromArray:minSizeConstraints]; 517 | } 518 | 519 | // Square aspect ratio, if set 520 | if (self.square) { 521 | NSLayoutConstraint *square = [NSLayoutConstraint constraintWithItem:bezel attribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:bezel attribute:NSLayoutAttributeWidth multiplier:1.f constant:0]; 522 | square.priority = 997.f; 523 | [bezelConstraints addObject:square]; 524 | } 525 | 526 | // Top and bottom spacing 527 | [topSpacer addConstraint:[NSLayoutConstraint constraintWithItem:topSpacer attribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationGreaterThanOrEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.f constant:margin]]; 528 | [bottomSpacer addConstraint:[NSLayoutConstraint constraintWithItem:bottomSpacer attribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationGreaterThanOrEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.f constant:margin]]; 529 | // Top and bottom spaces should be equal 530 | [bezelConstraints addObject:[NSLayoutConstraint constraintWithItem:topSpacer attribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:bottomSpacer attribute:NSLayoutAttributeHeight multiplier:1.f constant:0.f]]; 531 | 532 | // Layout subviews in bezel 533 | NSMutableArray *paddingConstraints = [NSMutableArray new]; 534 | [subviews enumerateObjectsUsingBlock:^(UIView *view, NSUInteger idx, BOOL *stop) { 535 | // Center in bezel 536 | [bezelConstraints addObject:[NSLayoutConstraint constraintWithItem:view attribute:NSLayoutAttributeCenterX relatedBy:NSLayoutRelationEqual toItem:bezel attribute:NSLayoutAttributeCenterX multiplier:1.f constant:0.f]]; 537 | // Ensure the minimum edge margin is kept 538 | [bezelConstraints addObjectsFromArray:[NSLayoutConstraint constraintsWithVisualFormat:@"|-(>=margin)-[view]-(>=margin)-|" options:0 metrics:metrics views:NSDictionaryOfVariableBindings(view)]]; 539 | // Element spacing 540 | if (idx == 0) { 541 | // First, ensure spacing to bezel edge 542 | [bezelConstraints addObject:[NSLayoutConstraint constraintWithItem:view attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:bezel attribute:NSLayoutAttributeTop multiplier:1.f constant:0.f]]; 543 | } else if (idx == subviews.count - 1) { 544 | // Last, ensure spacigin to bezel edge 545 | [bezelConstraints addObject:[NSLayoutConstraint constraintWithItem:view attribute:NSLayoutAttributeBottom relatedBy:NSLayoutRelationEqual toItem:bezel attribute:NSLayoutAttributeBottom multiplier:1.f constant:0.f]]; 546 | } 547 | if (idx > 0) { 548 | // Has previous 549 | NSLayoutConstraint *padding = [NSLayoutConstraint constraintWithItem:view attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:subviews[idx - 1] attribute:NSLayoutAttributeBottom multiplier:1.f constant:0.f]; 550 | [bezelConstraints addObject:padding]; 551 | [paddingConstraints addObject:padding]; 552 | } 553 | }]; 554 | 555 | [bezel addConstraints:bezelConstraints]; 556 | self.bezelConstraints = bezelConstraints; 557 | 558 | self.paddingConstraints = [paddingConstraints copy]; 559 | [self updatePaddingConstraints]; 560 | 561 | [super updateConstraints]; 562 | } 563 | 564 | - (void)layoutSubviews { 565 | [self updatePaddingConstraints]; 566 | [super layoutSubviews]; 567 | } 568 | 569 | - (void)updatePaddingConstraints { 570 | // Set padding dynamically, depending on whether the view is visible or not 571 | __block BOOL hasVisibleAncestors = NO; 572 | [self.paddingConstraints enumerateObjectsUsingBlock:^(NSLayoutConstraint *padding, NSUInteger idx, BOOL *stop) { 573 | UIView *firstView = (UIView *)padding.firstItem; 574 | UIView *secondView = (UIView *)padding.secondItem; 575 | BOOL firstVisible = !firstView.hidden && !CGSizeEqualToSize(firstView.intrinsicContentSize, CGSizeZero); 576 | BOOL secondVisible = !secondView.hidden && !CGSizeEqualToSize(secondView.intrinsicContentSize, CGSizeZero); 577 | // Set if both views are visible of if there's a visible view on top that yet doesn't have padding 578 | // added relative to the current view 579 | padding.constant = (firstVisible && (secondVisible || hasVisibleAncestors)) ? MBDefaultPadding : 0.f; 580 | hasVisibleAncestors |= secondVisible; 581 | }]; 582 | } 583 | 584 | - (void)applyPriority:(UILayoutPriority)priority toConstraints:(NSArray *)constraints { 585 | for (NSLayoutConstraint *constraint in constraints) { 586 | constraint.priority = priority; 587 | } 588 | } 589 | 590 | #pragma mark - Properties 591 | 592 | - (void)setMode:(MBProgressHUDMode)mode { 593 | if (mode != _mode) { 594 | _mode = mode; 595 | [self updateIndicators]; 596 | } 597 | } 598 | 599 | - (void)setCustomView:(UIView *)customView { 600 | if (customView != _customView) { 601 | _customView = customView; 602 | if (self.mode == MBProgressHUDModeCustomView) { 603 | [self updateIndicators]; 604 | } 605 | } 606 | } 607 | 608 | - (void)setOffset:(CGPoint)offset { 609 | if (!CGPointEqualToPoint(offset, _offset)) { 610 | _offset = offset; 611 | [self setNeedsUpdateConstraints]; 612 | } 613 | } 614 | 615 | - (void)setMargin:(CGFloat)margin { 616 | if (margin != margin) { 617 | _margin = margin; 618 | [self setNeedsUpdateConstraints]; 619 | } 620 | } 621 | 622 | - (void)setMinSize:(CGSize)minSize { 623 | if (!CGSizeEqualToSize(minSize, _minSize)) { 624 | _minSize = minSize; 625 | [self setNeedsUpdateConstraints]; 626 | } 627 | } 628 | 629 | - (void)setSquare:(BOOL)square { 630 | if (square != _square) { 631 | _square = square; 632 | [self setNeedsUpdateConstraints]; 633 | } 634 | } 635 | 636 | - (void)setProgress:(float)progress { 637 | if (progress != _progress) { 638 | _progress = progress; 639 | UIView *indicator = self.indicator; 640 | if ([indicator respondsToSelector:@selector(setProgress:)]) { 641 | [(id)indicator setValue:@(self.progress) forKey:@"progress"]; 642 | } 643 | } 644 | } 645 | 646 | - (void)setContentColor:(UIColor *)contentColor { 647 | if (contentColor != _contentColor && ![contentColor isEqual:_contentColor]) { 648 | _contentColor = contentColor; 649 | [self updateViewsForColor:contentColor]; 650 | } 651 | } 652 | 653 | - (void)setDefaultMotionEffectsEnabled:(BOOL)defaultMotionEffectsEnabled { 654 | if (defaultMotionEffectsEnabled != _defaultMotionEffectsEnabled) { 655 | _defaultMotionEffectsEnabled = defaultMotionEffectsEnabled; 656 | [self updateBezelMotionEffects]; 657 | } 658 | } 659 | 660 | #pragma mark - Notifications 661 | 662 | - (void)registerForNotifications { 663 | #if !TARGET_OS_TV 664 | NSNotificationCenter *nc = [NSNotificationCenter defaultCenter]; 665 | 666 | [nc addObserver:self selector:@selector(statusBarOrientationDidChange:) 667 | name:UIApplicationDidChangeStatusBarOrientationNotification object:nil]; 668 | #endif 669 | } 670 | 671 | - (void)unregisterFromNotifications { 672 | #if !TARGET_OS_TV 673 | NSNotificationCenter *nc = [NSNotificationCenter defaultCenter]; 674 | [nc removeObserver:self name:UIApplicationDidChangeStatusBarOrientationNotification object:nil]; 675 | #endif 676 | } 677 | 678 | #if !TARGET_OS_TV 679 | - (void)statusBarOrientationDidChange:(NSNotification *)notification { 680 | UIView *superview = self.superview; 681 | if (!superview) { 682 | return; 683 | } else { 684 | [self updateForCurrentOrientationAnimated:YES]; 685 | } 686 | } 687 | #endif 688 | 689 | - (void)updateForCurrentOrientationAnimated:(BOOL)animated { 690 | // Stay in sync with the superview in any case 691 | if (self.superview) { 692 | self.bounds = self.superview.bounds; 693 | } 694 | 695 | // Not needed on iOS 8+, compile out when the deployment target allows, 696 | // to avoid sharedApplication problems on extension targets 697 | #if __IPHONE_OS_VERSION_MIN_REQUIRED < 80000 698 | // Only needed pre iOS 8 when added to a window 699 | BOOL iOS8OrLater = kCFCoreFoundationVersionNumber >= kCFCoreFoundationVersionNumber_iOS_8_0; 700 | if (iOS8OrLater || ![self.superview isKindOfClass:[UIWindow class]]) return; 701 | 702 | // Make extension friendly 703 | Class UIApplicationClass = NSClassFromString(@"UIApplication"); 704 | if(UIApplicationClass && [UIApplicationClass respondsToSelector:@selector(sharedApplication)]) { 705 | UIApplication *application = [UIApplication performSelector:@selector(sharedApplication)]; 706 | 707 | UIInterfaceOrientation orientation = application.statusBarOrientation; 708 | CGFloat radians = 0; 709 | if (UIInterfaceOrientationIsLandscape(orientation)) { 710 | radians = orientation == UIInterfaceOrientationLandscapeLeft ? -(CGFloat)M_PI_2 : (CGFloat)M_PI_2; 711 | // Window coordinates differ! 712 | self.bounds = CGRectMake(0, 0, self.bounds.size.height, self.bounds.size.width); 713 | } else { 714 | radians = orientation == UIInterfaceOrientationPortraitUpsideDown ? (CGFloat)M_PI : 0.f; 715 | } 716 | 717 | if (animated) { 718 | [UIView animateWithDuration:0.3 animations:^{ 719 | self.transform = CGAffineTransformMakeRotation(radians); 720 | }]; 721 | } else { 722 | self.transform = CGAffineTransformMakeRotation(radians); 723 | } 724 | } 725 | #endif 726 | } 727 | 728 | @end 729 | 730 | 731 | @implementation MBRoundProgressView 732 | 733 | #pragma mark - Lifecycle 734 | 735 | - (id)init { 736 | return [self initWithFrame:CGRectMake(0.f, 0.f, 37.f, 37.f)]; 737 | } 738 | 739 | - (id)initWithFrame:(CGRect)frame { 740 | self = [super initWithFrame:frame]; 741 | if (self) { 742 | self.backgroundColor = [UIColor clearColor]; 743 | self.opaque = NO; 744 | _progress = 0.f; 745 | _annular = NO; 746 | _progressTintColor = [[UIColor alloc] initWithWhite:1.f alpha:1.f]; 747 | _backgroundTintColor = [[UIColor alloc] initWithWhite:1.f alpha:.1f]; 748 | } 749 | return self; 750 | } 751 | 752 | #pragma mark - Layout 753 | 754 | - (CGSize)intrinsicContentSize { 755 | return CGSizeMake(37.f, 37.f); 756 | } 757 | 758 | #pragma mark - Properties 759 | 760 | - (void)setProgress:(float)progress { 761 | if (progress != _progress) { 762 | _progress = progress; 763 | [self setNeedsDisplay]; 764 | } 765 | } 766 | 767 | - (void)setProgressTintColor:(UIColor *)progressTintColor { 768 | NSAssert(progressTintColor, @"The color should not be nil."); 769 | if (progressTintColor != _progressTintColor && ![progressTintColor isEqual:_progressTintColor]) { 770 | _progressTintColor = progressTintColor; 771 | [self setNeedsDisplay]; 772 | } 773 | } 774 | 775 | - (void)setBackgroundTintColor:(UIColor *)backgroundTintColor { 776 | NSAssert(backgroundTintColor, @"The color should not be nil."); 777 | if (backgroundTintColor != _backgroundTintColor && ![backgroundTintColor isEqual:_backgroundTintColor]) { 778 | _backgroundTintColor = backgroundTintColor; 779 | [self setNeedsDisplay]; 780 | } 781 | } 782 | 783 | #pragma mark - Drawing 784 | 785 | - (void)drawRect:(CGRect)rect { 786 | CGContextRef context = UIGraphicsGetCurrentContext(); 787 | BOOL isPreiOS7 = kCFCoreFoundationVersionNumber < kCFCoreFoundationVersionNumber_iOS_7_0; 788 | 789 | if (_annular) { 790 | // Draw background 791 | CGFloat lineWidth = isPreiOS7 ? 5.f : 2.f; 792 | UIBezierPath *processBackgroundPath = [UIBezierPath bezierPath]; 793 | processBackgroundPath.lineWidth = lineWidth; 794 | processBackgroundPath.lineCapStyle = kCGLineCapButt; 795 | CGPoint center = CGPointMake(CGRectGetMidX(self.bounds), CGRectGetMidY(self.bounds)); 796 | CGFloat radius = (self.bounds.size.width - lineWidth)/2; 797 | CGFloat startAngle = - ((float)M_PI / 2); // 90 degrees 798 | CGFloat endAngle = (2 * (float)M_PI) + startAngle; 799 | [processBackgroundPath addArcWithCenter:center radius:radius startAngle:startAngle endAngle:endAngle clockwise:YES]; 800 | [_backgroundTintColor set]; 801 | [processBackgroundPath stroke]; 802 | // Draw progress 803 | UIBezierPath *processPath = [UIBezierPath bezierPath]; 804 | processPath.lineCapStyle = isPreiOS7 ? kCGLineCapRound : kCGLineCapSquare; 805 | processPath.lineWidth = lineWidth; 806 | endAngle = (self.progress * 2 * (float)M_PI) + startAngle; 807 | [processPath addArcWithCenter:center radius:radius startAngle:startAngle endAngle:endAngle clockwise:YES]; 808 | [_progressTintColor set]; 809 | [processPath stroke]; 810 | } else { 811 | // Draw background 812 | CGFloat lineWidth = 2.f; 813 | CGRect allRect = self.bounds; 814 | CGRect circleRect = CGRectInset(allRect, lineWidth/2.f, lineWidth/2.f); 815 | CGPoint center = CGPointMake(CGRectGetMidX(self.bounds), CGRectGetMidY(self.bounds)); 816 | [_progressTintColor setStroke]; 817 | [_backgroundTintColor setFill]; 818 | CGContextSetLineWidth(context, lineWidth); 819 | if (isPreiOS7) { 820 | CGContextFillEllipseInRect(context, circleRect); 821 | } 822 | CGContextStrokeEllipseInRect(context, circleRect); 823 | // 90 degrees 824 | CGFloat startAngle = - ((float)M_PI / 2.f); 825 | // Draw progress 826 | if (isPreiOS7) { 827 | CGFloat radius = (CGRectGetWidth(self.bounds) / 2.f) - lineWidth; 828 | CGFloat endAngle = (self.progress * 2.f * (float)M_PI) + startAngle; 829 | [_progressTintColor setFill]; 830 | CGContextMoveToPoint(context, center.x, center.y); 831 | CGContextAddArc(context, center.x, center.y, radius, startAngle, endAngle, 0); 832 | CGContextClosePath(context); 833 | CGContextFillPath(context); 834 | } else { 835 | UIBezierPath *processPath = [UIBezierPath bezierPath]; 836 | processPath.lineCapStyle = kCGLineCapButt; 837 | processPath.lineWidth = lineWidth * 2.f; 838 | CGFloat radius = (CGRectGetWidth(self.bounds) / 2.f) - (processPath.lineWidth / 2.f); 839 | CGFloat endAngle = (self.progress * 2.f * (float)M_PI) + startAngle; 840 | [processPath addArcWithCenter:center radius:radius startAngle:startAngle endAngle:endAngle clockwise:YES]; 841 | // Ensure that we don't get color overlaping when _progressTintColor alpha < 1.f. 842 | CGContextSetBlendMode(context, kCGBlendModeCopy); 843 | [_progressTintColor set]; 844 | [processPath stroke]; 845 | } 846 | } 847 | } 848 | 849 | @end 850 | 851 | 852 | @implementation MBBarProgressView 853 | 854 | #pragma mark - Lifecycle 855 | 856 | - (id)init { 857 | return [self initWithFrame:CGRectMake(.0f, .0f, 120.0f, 20.0f)]; 858 | } 859 | 860 | - (id)initWithFrame:(CGRect)frame { 861 | self = [super initWithFrame:frame]; 862 | if (self) { 863 | _progress = 0.f; 864 | _lineColor = [UIColor whiteColor]; 865 | _progressColor = [UIColor whiteColor]; 866 | _progressRemainingColor = [UIColor clearColor]; 867 | self.backgroundColor = [UIColor clearColor]; 868 | self.opaque = NO; 869 | } 870 | return self; 871 | } 872 | 873 | #pragma mark - Layout 874 | 875 | - (CGSize)intrinsicContentSize { 876 | BOOL isPreiOS7 = kCFCoreFoundationVersionNumber < kCFCoreFoundationVersionNumber_iOS_7_0; 877 | return CGSizeMake(120.f, isPreiOS7 ? 20.f : 10.f); 878 | } 879 | 880 | #pragma mark - Properties 881 | 882 | - (void)setProgress:(float)progress { 883 | if (progress != _progress) { 884 | _progress = progress; 885 | [self setNeedsDisplay]; 886 | } 887 | } 888 | 889 | - (void)setProgressColor:(UIColor *)progressColor { 890 | NSAssert(progressColor, @"The color should not be nil."); 891 | if (progressColor != _progressColor && ![progressColor isEqual:_progressColor]) { 892 | _progressColor = progressColor; 893 | [self setNeedsDisplay]; 894 | } 895 | } 896 | 897 | - (void)setProgressRemainingColor:(UIColor *)progressRemainingColor { 898 | NSAssert(progressRemainingColor, @"The color should not be nil."); 899 | if (progressRemainingColor != _progressRemainingColor && ![progressRemainingColor isEqual:_progressRemainingColor]) { 900 | _progressRemainingColor = progressRemainingColor; 901 | [self setNeedsDisplay]; 902 | } 903 | } 904 | 905 | #pragma mark - Drawing 906 | 907 | - (void)drawRect:(CGRect)rect { 908 | CGContextRef context = UIGraphicsGetCurrentContext(); 909 | 910 | CGContextSetLineWidth(context, 2); 911 | CGContextSetStrokeColorWithColor(context,[_lineColor CGColor]); 912 | CGContextSetFillColorWithColor(context, [_progressRemainingColor CGColor]); 913 | 914 | // Draw background 915 | CGFloat radius = (rect.size.height / 2) - 2; 916 | CGContextMoveToPoint(context, 2, rect.size.height/2); 917 | CGContextAddArcToPoint(context, 2, 2, radius + 2, 2, radius); 918 | CGContextAddLineToPoint(context, rect.size.width - radius - 2, 2); 919 | CGContextAddArcToPoint(context, rect.size.width - 2, 2, rect.size.width - 2, rect.size.height / 2, radius); 920 | CGContextAddArcToPoint(context, rect.size.width - 2, rect.size.height - 2, rect.size.width - radius - 2, rect.size.height - 2, radius); 921 | CGContextAddLineToPoint(context, radius + 2, rect.size.height - 2); 922 | CGContextAddArcToPoint(context, 2, rect.size.height - 2, 2, rect.size.height/2, radius); 923 | CGContextFillPath(context); 924 | 925 | // Draw border 926 | CGContextMoveToPoint(context, 2, rect.size.height/2); 927 | CGContextAddArcToPoint(context, 2, 2, radius + 2, 2, radius); 928 | CGContextAddLineToPoint(context, rect.size.width - radius - 2, 2); 929 | CGContextAddArcToPoint(context, rect.size.width - 2, 2, rect.size.width - 2, rect.size.height / 2, radius); 930 | CGContextAddArcToPoint(context, rect.size.width - 2, rect.size.height - 2, rect.size.width - radius - 2, rect.size.height - 2, radius); 931 | CGContextAddLineToPoint(context, radius + 2, rect.size.height - 2); 932 | CGContextAddArcToPoint(context, 2, rect.size.height - 2, 2, rect.size.height/2, radius); 933 | CGContextStrokePath(context); 934 | 935 | CGContextSetFillColorWithColor(context, [_progressColor CGColor]); 936 | radius = radius - 2; 937 | CGFloat amount = self.progress * rect.size.width; 938 | 939 | // Progress in the middle area 940 | if (amount >= radius + 4 && amount <= (rect.size.width - radius - 4)) { 941 | CGContextMoveToPoint(context, 4, rect.size.height/2); 942 | CGContextAddArcToPoint(context, 4, 4, radius + 4, 4, radius); 943 | CGContextAddLineToPoint(context, amount, 4); 944 | CGContextAddLineToPoint(context, amount, radius + 4); 945 | 946 | CGContextMoveToPoint(context, 4, rect.size.height/2); 947 | CGContextAddArcToPoint(context, 4, rect.size.height - 4, radius + 4, rect.size.height - 4, radius); 948 | CGContextAddLineToPoint(context, amount, rect.size.height - 4); 949 | CGContextAddLineToPoint(context, amount, radius + 4); 950 | 951 | CGContextFillPath(context); 952 | } 953 | 954 | // Progress in the right arc 955 | else if (amount > radius + 4) { 956 | CGFloat x = amount - (rect.size.width - radius - 4); 957 | 958 | CGContextMoveToPoint(context, 4, rect.size.height/2); 959 | CGContextAddArcToPoint(context, 4, 4, radius + 4, 4, radius); 960 | CGContextAddLineToPoint(context, rect.size.width - radius - 4, 4); 961 | CGFloat angle = -acos(x/radius); 962 | if (isnan(angle)) angle = 0; 963 | CGContextAddArc(context, rect.size.width - radius - 4, rect.size.height/2, radius, M_PI, angle, 0); 964 | CGContextAddLineToPoint(context, amount, rect.size.height/2); 965 | 966 | CGContextMoveToPoint(context, 4, rect.size.height/2); 967 | CGContextAddArcToPoint(context, 4, rect.size.height - 4, radius + 4, rect.size.height - 4, radius); 968 | CGContextAddLineToPoint(context, rect.size.width - radius - 4, rect.size.height - 4); 969 | angle = acos(x/radius); 970 | if (isnan(angle)) angle = 0; 971 | CGContextAddArc(context, rect.size.width - radius - 4, rect.size.height/2, radius, -M_PI, angle, 1); 972 | CGContextAddLineToPoint(context, amount, rect.size.height/2); 973 | 974 | CGContextFillPath(context); 975 | } 976 | 977 | // Progress is in the left arc 978 | else if (amount < radius + 4 && amount > 0) { 979 | CGContextMoveToPoint(context, 4, rect.size.height/2); 980 | CGContextAddArcToPoint(context, 4, 4, radius + 4, 4, radius); 981 | CGContextAddLineToPoint(context, radius + 4, rect.size.height/2); 982 | 983 | CGContextMoveToPoint(context, 4, rect.size.height/2); 984 | CGContextAddArcToPoint(context, 4, rect.size.height - 4, radius + 4, rect.size.height - 4, radius); 985 | CGContextAddLineToPoint(context, radius + 4, rect.size.height/2); 986 | 987 | CGContextFillPath(context); 988 | } 989 | } 990 | 991 | @end 992 | 993 | 994 | @interface MBBackgroundView () 995 | 996 | #if __IPHONE_OS_VERSION_MAX_ALLOWED >= 80000 997 | @property UIVisualEffectView *effectView; 998 | #endif 999 | @property UIToolbar *toolbar; 1000 | 1001 | @end 1002 | 1003 | 1004 | @implementation MBBackgroundView 1005 | 1006 | #pragma mark - Lifecycle 1007 | 1008 | - (instancetype)initWithFrame:(CGRect)frame { 1009 | if ((self = [super initWithFrame:frame])) { 1010 | if (kCFCoreFoundationVersionNumber >= kCFCoreFoundationVersionNumber_iOS_7_0) { 1011 | _style = MBProgressHUDBackgroundStyleBlur; 1012 | #if __IPHONE_OS_VERSION_MAX_ALLOWED >= 80000 1013 | _color = [UIColor colorWithWhite:0.8f alpha:0.6f]; 1014 | #else 1015 | _color = [UIColor colorWithWhite:0.95f alpha:0.6f]; 1016 | #endif 1017 | } else { 1018 | _style = MBProgressHUDBackgroundStyleSolidColor; 1019 | _color = [[UIColor blackColor] colorWithAlphaComponent:0.8]; 1020 | } 1021 | 1022 | self.clipsToBounds = YES; 1023 | 1024 | [self updateForBackgroundStyle]; 1025 | } 1026 | return self; 1027 | } 1028 | 1029 | #pragma mark - Layout 1030 | 1031 | - (CGSize)intrinsicContentSize { 1032 | // Smallest size possible. Content pushes against this. 1033 | return CGSizeZero; 1034 | } 1035 | 1036 | #pragma mark - Appearance 1037 | 1038 | - (void)setStyle:(MBProgressHUDBackgroundStyle)style { 1039 | if (style == MBProgressHUDBackgroundStyleBlur && kCFCoreFoundationVersionNumber < kCFCoreFoundationVersionNumber_iOS_7_0) { 1040 | style = MBProgressHUDBackgroundStyleSolidColor; 1041 | } 1042 | if (_style != style) { 1043 | _style = style; 1044 | [self updateForBackgroundStyle]; 1045 | } 1046 | } 1047 | 1048 | - (void)setColor:(UIColor *)color { 1049 | NSAssert(color, @"The color should not be nil."); 1050 | if (color != _color && ![color isEqual:_color]) { 1051 | _color = color; 1052 | [self updateViewsForColor:color]; 1053 | } 1054 | } 1055 | 1056 | /////////////////////////////////////////////////////////////////////////////////////////// 1057 | #pragma mark - Views 1058 | 1059 | - (void)updateForBackgroundStyle { 1060 | MBProgressHUDBackgroundStyle style = self.style; 1061 | if (style == MBProgressHUDBackgroundStyleBlur) { 1062 | #if __IPHONE_OS_VERSION_MAX_ALLOWED >= 80000 1063 | UIBlurEffect *effect = [UIBlurEffect effectWithStyle:UIBlurEffectStyleLight]; 1064 | UIVisualEffectView *effectView = [[UIVisualEffectView alloc] initWithEffect:effect]; 1065 | [self addSubview:effectView]; 1066 | effectView.frame = self.bounds; 1067 | effectView.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth; 1068 | self.backgroundColor = self.color; 1069 | self.layer.allowsGroupOpacity = NO; 1070 | self.effectView = effectView; 1071 | #else 1072 | UIToolbar *toolbar = [[UIToolbar alloc] initWithFrame:CGRectInset(self.bounds, -100.f, -100.f)]; 1073 | toolbar.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth; 1074 | toolbar.barTintColor = self.color; 1075 | toolbar.translucent = YES; 1076 | toolbar.barTintColor = color; 1077 | [self addSubview:toolbar]; 1078 | self.toolbar = toolbar; 1079 | #endif 1080 | } else { 1081 | #if __IPHONE_OS_VERSION_MAX_ALLOWED >= 80000 1082 | [self.effectView removeFromSuperview]; 1083 | self.effectView = nil; 1084 | #else 1085 | [self.toolbar removeFromSuperview]; 1086 | self.toolbar = nil; 1087 | #endif 1088 | self.backgroundColor = self.color; 1089 | } 1090 | } 1091 | 1092 | - (void)updateViewsForColor:(UIColor *)color { 1093 | if (self.style == MBProgressHUDBackgroundStyleBlur) { 1094 | #if __IPHONE_OS_VERSION_MAX_ALLOWED >= 80000 1095 | self.backgroundColor = self.color; 1096 | #else 1097 | self.toolbar.barTintColor = color; 1098 | #endif 1099 | } else { 1100 | self.backgroundColor = self.color; 1101 | } 1102 | } 1103 | 1104 | @end 1105 | 1106 | 1107 | @implementation MBProgressHUD (Deprecated) 1108 | 1109 | #pragma mark - Class 1110 | 1111 | + (NSUInteger)hideAllHUDsForView:(UIView *)view animated:(BOOL)animated { 1112 | NSArray *huds = [MBProgressHUD allHUDsForView:view]; 1113 | for (MBProgressHUD *hud in huds) { 1114 | hud.removeFromSuperViewOnHide = YES; 1115 | [hud hideAnimated:animated]; 1116 | } 1117 | return [huds count]; 1118 | } 1119 | 1120 | + (NSArray *)allHUDsForView:(UIView *)view { 1121 | NSMutableArray *huds = [NSMutableArray array]; 1122 | NSArray *subviews = view.subviews; 1123 | for (UIView *aView in subviews) { 1124 | if ([aView isKindOfClass:self]) { 1125 | [huds addObject:aView]; 1126 | } 1127 | } 1128 | return [NSArray arrayWithArray:huds]; 1129 | } 1130 | 1131 | #pragma mark - Lifecycle 1132 | 1133 | - (id)initWithWindow:(UIWindow *)window { 1134 | return [self initWithView:window]; 1135 | } 1136 | 1137 | #pragma mark - Show & hide 1138 | 1139 | - (void)show:(BOOL)animated { 1140 | [self showAnimated:animated]; 1141 | } 1142 | 1143 | - (void)hide:(BOOL)animated { 1144 | [self hideAnimated:animated]; 1145 | } 1146 | 1147 | - (void)hide:(BOOL)animated afterDelay:(NSTimeInterval)delay { 1148 | [self hideAnimated:animated afterDelay:delay]; 1149 | } 1150 | 1151 | #pragma mark - Threading 1152 | 1153 | - (void)showWhileExecuting:(SEL)method onTarget:(id)target withObject:(id)object animated:(BOOL)animated { 1154 | [self showAnimated:animated whileExecutingBlock:^{ 1155 | #pragma clang diagnostic push 1156 | #pragma clang diagnostic ignored "-Warc-performSelector-leaks" 1157 | // Start executing the requested task 1158 | [target performSelector:method withObject:object]; 1159 | #pragma clang diagnostic pop 1160 | }]; 1161 | } 1162 | 1163 | - (void)showAnimated:(BOOL)animated whileExecutingBlock:(dispatch_block_t)block { 1164 | dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0); 1165 | [self showAnimated:animated whileExecutingBlock:block onQueue:queue completionBlock:NULL]; 1166 | } 1167 | 1168 | - (void)showAnimated:(BOOL)animated whileExecutingBlock:(dispatch_block_t)block completionBlock:(void (^)())completion { 1169 | dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0); 1170 | [self showAnimated:animated whileExecutingBlock:block onQueue:queue completionBlock:completion]; 1171 | } 1172 | 1173 | - (void)showAnimated:(BOOL)animated whileExecutingBlock:(dispatch_block_t)block onQueue:(dispatch_queue_t)queue { 1174 | [self showAnimated:animated whileExecutingBlock:block onQueue:queue completionBlock:NULL]; 1175 | } 1176 | 1177 | - (void)showAnimated:(BOOL)animated whileExecutingBlock:(dispatch_block_t)block onQueue:(dispatch_queue_t)queue completionBlock:(nullable MBProgressHUDCompletionBlock)completion { 1178 | self.taskInProgress = YES; 1179 | self.completionBlock = completion; 1180 | dispatch_async(queue, ^(void) { 1181 | block(); 1182 | dispatch_async(dispatch_get_main_queue(), ^(void) { 1183 | [self cleanUp]; 1184 | }); 1185 | }); 1186 | [self showAnimated:animated]; 1187 | } 1188 | 1189 | - (void)cleanUp { 1190 | self.taskInProgress = NO; 1191 | [self hideAnimated:self.useAnimation]; 1192 | } 1193 | 1194 | #pragma mark - Labels 1195 | 1196 | - (NSString *)labelText { 1197 | return self.label.text; 1198 | } 1199 | 1200 | - (void)setLabelText:(NSString *)labelText { 1201 | MBMainThreadAssert(); 1202 | self.label.text = labelText; 1203 | } 1204 | 1205 | - (UIFont *)labelFont { 1206 | return self.label.font; 1207 | } 1208 | 1209 | - (void)setLabelFont:(UIFont *)labelFont { 1210 | MBMainThreadAssert(); 1211 | self.label.font = labelFont; 1212 | } 1213 | 1214 | - (UIColor *)labelColor { 1215 | return self.label.textColor; 1216 | } 1217 | 1218 | - (void)setLabelColor:(UIColor *)labelColor { 1219 | MBMainThreadAssert(); 1220 | self.label.textColor = labelColor; 1221 | } 1222 | 1223 | - (NSString *)detailsLabelText { 1224 | return self.detailsLabel.text; 1225 | } 1226 | 1227 | - (void)setDetailsLabelText:(NSString *)detailsLabelText { 1228 | MBMainThreadAssert(); 1229 | self.detailsLabel.text = detailsLabelText; 1230 | } 1231 | 1232 | - (UIFont *)detailsLabelFont { 1233 | return self.detailsLabel.font; 1234 | } 1235 | 1236 | - (void)setDetailsLabelFont:(UIFont *)detailsLabelFont { 1237 | MBMainThreadAssert(); 1238 | self.detailsLabel.font = detailsLabelFont; 1239 | } 1240 | 1241 | - (UIColor *)detailsLabelColor { 1242 | return self.detailsLabel.textColor; 1243 | } 1244 | 1245 | - (void)setDetailsLabelColor:(UIColor *)detailsLabelColor { 1246 | MBMainThreadAssert(); 1247 | self.detailsLabel.textColor = detailsLabelColor; 1248 | } 1249 | 1250 | - (CGFloat)opacity { 1251 | return _opacity; 1252 | } 1253 | 1254 | - (void)setOpacity:(CGFloat)opacity { 1255 | MBMainThreadAssert(); 1256 | _opacity = opacity; 1257 | } 1258 | 1259 | - (UIColor *)color { 1260 | return self.bezelView.color; 1261 | } 1262 | 1263 | - (void)setColor:(UIColor *)color { 1264 | MBMainThreadAssert(); 1265 | self.bezelView.color = color; 1266 | } 1267 | 1268 | - (CGFloat)yOffset { 1269 | return self.offset.y; 1270 | } 1271 | 1272 | - (void)setYOffset:(CGFloat)yOffset { 1273 | MBMainThreadAssert(); 1274 | self.offset = CGPointMake(self.offset.x, yOffset); 1275 | } 1276 | 1277 | - (CGFloat)xOffset { 1278 | return self.offset.x; 1279 | } 1280 | 1281 | - (void)setXOffset:(CGFloat)xOffset { 1282 | MBMainThreadAssert(); 1283 | self.offset = CGPointMake(xOffset, self.offset.y); 1284 | } 1285 | 1286 | - (CGFloat)cornerRadius { 1287 | return self.bezelView.layer.cornerRadius; 1288 | } 1289 | 1290 | - (void)setCornerRadius:(CGFloat)cornerRadius { 1291 | MBMainThreadAssert(); 1292 | self.bezelView.layer.cornerRadius = cornerRadius; 1293 | } 1294 | 1295 | - (BOOL)dimBackground { 1296 | MBBackgroundView *backgroundView = self.backgroundView; 1297 | UIColor *dimmedColor = [UIColor colorWithWhite:0.f alpha:.2f]; 1298 | return backgroundView.style == MBProgressHUDBackgroundStyleSolidColor && [backgroundView.color isEqual:dimmedColor]; 1299 | } 1300 | 1301 | - (void)setDimBackground:(BOOL)dimBackground { 1302 | MBMainThreadAssert(); 1303 | self.backgroundView.style = MBProgressHUDBackgroundStyleSolidColor; 1304 | self.backgroundView.color = dimBackground ? [UIColor colorWithWhite:0.f alpha:.2f] : [UIColor clearColor]; 1305 | } 1306 | 1307 | - (CGSize)size { 1308 | return self.bezelView.frame.size; 1309 | } 1310 | 1311 | - (UIColor *)activityIndicatorColor { 1312 | return _activityIndicatorColor; 1313 | } 1314 | 1315 | - (void)setActivityIndicatorColor:(UIColor *)activityIndicatorColor { 1316 | if (activityIndicatorColor != _activityIndicatorColor) { 1317 | _activityIndicatorColor = activityIndicatorColor; 1318 | UIActivityIndicatorView *indicator = (UIActivityIndicatorView *)self.indicator; 1319 | if ([indicator isKindOfClass:[UIActivityIndicatorView class]]) { 1320 | [indicator setColor:activityIndicatorColor]; 1321 | } 1322 | } 1323 | } 1324 | 1325 | @end 1326 | 1327 | @implementation MBProgressHUDRoundedButton 1328 | 1329 | #pragma mark - Lifecycle 1330 | 1331 | - (instancetype)initWithFrame:(CGRect)frame { 1332 | self = [super initWithFrame:frame]; 1333 | if (self) { 1334 | CALayer *layer = self.layer; 1335 | layer.borderWidth = 1.f; 1336 | } 1337 | return self; 1338 | } 1339 | 1340 | #pragma mark - Layout 1341 | 1342 | - (void)layoutSubviews { 1343 | [super layoutSubviews]; 1344 | // Fully rounded corners. 1345 | CGFloat height = CGRectGetHeight(self.bounds); 1346 | self.layer.cornerRadius = ceil(height / 2.f); 1347 | } 1348 | 1349 | - (CGSize)intrinsicContentSize { 1350 | // Only show, if we have associated control events. 1351 | if (self.allControlEvents == 0) return CGSizeZero; 1352 | CGSize size = [super intrinsicContentSize]; 1353 | // Add some side padding. 1354 | size.width += 20.f; 1355 | return size; 1356 | } 1357 | 1358 | #pragma mark - Color 1359 | 1360 | - (void)setTitleColor:(UIColor *)color forState:(UIControlState)state { 1361 | [super setTitleColor:color forState:state]; 1362 | // Update related colors. 1363 | [self setHighlighted:self.highlighted]; 1364 | self.layer.borderColor = color.CGColor; 1365 | } 1366 | 1367 | - (void)setHighlighted:(BOOL)highlighted { 1368 | [super setHighlighted:highlighted]; 1369 | UIColor *baseColor = [self titleColorForState:UIControlStateSelected]; 1370 | self.backgroundColor = highlighted ? [baseColor colorWithAlphaComponent:0.1f] : [UIColor clearColor]; 1371 | } 1372 | 1373 | @end 1374 | -------------------------------------------------------------------------------- /MBProgressHUD.podspec: -------------------------------------------------------------------------------- 1 | Pod::Spec.new do |s| 2 | s.name = "MBProgressHUD" 3 | s.version = "0.9.2" 4 | s.summary = "An iOS activity indicator view." 5 | s.description = <<-DESC 6 | MBProgressHUD is an iOS drop-in class that displays a translucent HUD 7 | with an indicator and/or labels while work is being done in a background thread. 8 | The HUD is meant as a replacement for the undocumented, private UIKit UIProgressHUD 9 | with some additional features. 10 | DESC 11 | s.homepage = "http://www.bukovinski.com" 12 | s.license = { :type => 'MIT', :file => 'LICENSE' } 13 | s.author = { 'Matej Bukovinski' => 'matej@bukovinski.com' } 14 | s.source = { :git => "https://github.com/matej/MBProgressHUD.git", :tag => s.version.to_s } 15 | s.platform = :ios 16 | s.source_files = '*.{h,m}' 17 | s.framework = "CoreGraphics" 18 | s.requires_arc = true 19 | end 20 | -------------------------------------------------------------------------------- /MBProgressHUD.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 1315DD7617804CBC0032507D /* MBProgressHUD.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = D286A7511518C70F00E13FB8 /* MBProgressHUD.h */; }; 11 | 1D104D931ACA371400973364 /* MBProgressHUD.m in Sources */ = {isa = PBXBuildFile; fileRef = D286A7521518C70F00E13FB8 /* MBProgressHUD.m */; }; 12 | 1D104D941ACA373100973364 /* MBProgressHUD.h in Headers */ = {isa = PBXBuildFile; fileRef = D286A7511518C70F00E13FB8 /* MBProgressHUD.h */; settings = {ATTRIBUTES = (Public, ); }; }; 13 | D286A74D1518C70F00E13FB8 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D286A74C1518C70F00E13FB8 /* Foundation.framework */; }; 14 | D286A7531518C70F00E13FB8 /* MBProgressHUD.m in Sources */ = {isa = PBXBuildFile; fileRef = D286A7521518C70F00E13FB8 /* MBProgressHUD.m */; }; 15 | D286A75E1518C89600E13FB8 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D286A75D1518C89600E13FB8 /* UIKit.framework */; }; 16 | D286A76F1518CAAD00E13FB8 /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D286A76E1518CAAD00E13FB8 /* CoreGraphics.framework */; }; 17 | /* End PBXBuildFile section */ 18 | 19 | /* Begin PBXCopyFilesBuildPhase section */ 20 | 1315DD7517804C970032507D /* CopyFiles */ = { 21 | isa = PBXCopyFilesBuildPhase; 22 | buildActionMask = 2147483647; 23 | dstPath = "include/${PRODUCT_NAME}"; 24 | dstSubfolderSpec = 16; 25 | files = ( 26 | 1315DD7617804CBC0032507D /* MBProgressHUD.h in CopyFiles */, 27 | ); 28 | runOnlyForDeploymentPostprocessing = 0; 29 | }; 30 | /* End PBXCopyFilesBuildPhase section */ 31 | 32 | /* Begin PBXFileReference section */ 33 | 1315DD73178045000032507D /* MBProgressHUD-Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "MBProgressHUD-Prefix.pch"; sourceTree = SOURCE_ROOT; }; 34 | 1D104D7A1ACA36CC00973364 /* MBProgressHUD.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = MBProgressHUD.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 35 | 1D104D951ACA376200973364 /* Framework-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "Framework-Info.plist"; sourceTree = SOURCE_ROOT; }; 36 | D286A7491518C70F00E13FB8 /* libMBProgressHUD.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libMBProgressHUD.a; sourceTree = BUILT_PRODUCTS_DIR; }; 37 | D286A74C1518C70F00E13FB8 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; 38 | D286A7511518C70F00E13FB8 /* MBProgressHUD.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MBProgressHUD.h; sourceTree = SOURCE_ROOT; }; 39 | D286A7521518C70F00E13FB8 /* MBProgressHUD.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MBProgressHUD.m; sourceTree = SOURCE_ROOT; }; 40 | D286A75D1518C89600E13FB8 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; }; 41 | D286A76E1518CAAD00E13FB8 /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; }; 42 | /* End PBXFileReference section */ 43 | 44 | /* Begin PBXFrameworksBuildPhase section */ 45 | 1D104D761ACA36CC00973364 /* Frameworks */ = { 46 | isa = PBXFrameworksBuildPhase; 47 | buildActionMask = 2147483647; 48 | files = ( 49 | ); 50 | runOnlyForDeploymentPostprocessing = 0; 51 | }; 52 | D286A7461518C70F00E13FB8 /* Frameworks */ = { 53 | isa = PBXFrameworksBuildPhase; 54 | buildActionMask = 2147483647; 55 | files = ( 56 | D286A75E1518C89600E13FB8 /* UIKit.framework in Frameworks */, 57 | D286A74D1518C70F00E13FB8 /* Foundation.framework in Frameworks */, 58 | D286A76F1518CAAD00E13FB8 /* CoreGraphics.framework in Frameworks */, 59 | ); 60 | runOnlyForDeploymentPostprocessing = 0; 61 | }; 62 | /* End PBXFrameworksBuildPhase section */ 63 | 64 | /* Begin PBXGroup section */ 65 | 1315DD72178044770032507D /* Supporting Files */ = { 66 | isa = PBXGroup; 67 | children = ( 68 | 1D104D951ACA376200973364 /* Framework-Info.plist */, 69 | 1315DD73178045000032507D /* MBProgressHUD-Prefix.pch */, 70 | ); 71 | name = "Supporting Files"; 72 | sourceTree = ""; 73 | }; 74 | D286A73E1518C70E00E13FB8 = { 75 | isa = PBXGroup; 76 | children = ( 77 | D286A74E1518C70F00E13FB8 /* MBProgressHUD */, 78 | D286A74B1518C70F00E13FB8 /* Frameworks */, 79 | D286A74A1518C70F00E13FB8 /* Products */, 80 | ); 81 | sourceTree = ""; 82 | }; 83 | D286A74A1518C70F00E13FB8 /* Products */ = { 84 | isa = PBXGroup; 85 | children = ( 86 | D286A7491518C70F00E13FB8 /* libMBProgressHUD.a */, 87 | 1D104D7A1ACA36CC00973364 /* MBProgressHUD.framework */, 88 | ); 89 | name = Products; 90 | sourceTree = ""; 91 | }; 92 | D286A74B1518C70F00E13FB8 /* Frameworks */ = { 93 | isa = PBXGroup; 94 | children = ( 95 | D286A75D1518C89600E13FB8 /* UIKit.framework */, 96 | D286A74C1518C70F00E13FB8 /* Foundation.framework */, 97 | D286A76E1518CAAD00E13FB8 /* CoreGraphics.framework */, 98 | ); 99 | name = Frameworks; 100 | sourceTree = ""; 101 | }; 102 | D286A74E1518C70F00E13FB8 /* MBProgressHUD */ = { 103 | isa = PBXGroup; 104 | children = ( 105 | D286A7511518C70F00E13FB8 /* MBProgressHUD.h */, 106 | D286A7521518C70F00E13FB8 /* MBProgressHUD.m */, 107 | 1315DD72178044770032507D /* Supporting Files */, 108 | ); 109 | path = MBProgressHUD; 110 | sourceTree = ""; 111 | }; 112 | /* End PBXGroup section */ 113 | 114 | /* Begin PBXHeadersBuildPhase section */ 115 | 1D104D771ACA36CC00973364 /* Headers */ = { 116 | isa = PBXHeadersBuildPhase; 117 | buildActionMask = 2147483647; 118 | files = ( 119 | 1D104D941ACA373100973364 /* MBProgressHUD.h in Headers */, 120 | ); 121 | runOnlyForDeploymentPostprocessing = 0; 122 | }; 123 | /* End PBXHeadersBuildPhase section */ 124 | 125 | /* Begin PBXNativeTarget section */ 126 | 1D104D791ACA36CC00973364 /* MBProgressHUD Framework */ = { 127 | isa = PBXNativeTarget; 128 | buildConfigurationList = 1D104D8D1ACA36CC00973364 /* Build configuration list for PBXNativeTarget "MBProgressHUD Framework" */; 129 | buildPhases = ( 130 | 1D104D751ACA36CC00973364 /* Sources */, 131 | 1D104D761ACA36CC00973364 /* Frameworks */, 132 | 1D104D771ACA36CC00973364 /* Headers */, 133 | 1D104D781ACA36CC00973364 /* Resources */, 134 | ); 135 | buildRules = ( 136 | ); 137 | dependencies = ( 138 | ); 139 | name = "MBProgressHUD Framework"; 140 | productName = "MBProgressHUD Framework"; 141 | productReference = 1D104D7A1ACA36CC00973364 /* MBProgressHUD.framework */; 142 | productType = "com.apple.product-type.framework"; 143 | }; 144 | D286A7481518C70F00E13FB8 /* MBProgressHUD Static Library */ = { 145 | isa = PBXNativeTarget; 146 | buildConfigurationList = D286A7561518C70F00E13FB8 /* Build configuration list for PBXNativeTarget "MBProgressHUD Static Library" */; 147 | buildPhases = ( 148 | D286A7451518C70F00E13FB8 /* Sources */, 149 | D286A7461518C70F00E13FB8 /* Frameworks */, 150 | 1315DD7517804C970032507D /* CopyFiles */, 151 | ); 152 | buildRules = ( 153 | ); 154 | dependencies = ( 155 | ); 156 | name = "MBProgressHUD Static Library"; 157 | productName = MBProgressHUD; 158 | productReference = D286A7491518C70F00E13FB8 /* libMBProgressHUD.a */; 159 | productType = "com.apple.product-type.library.static"; 160 | }; 161 | /* End PBXNativeTarget section */ 162 | 163 | /* Begin PBXProject section */ 164 | D286A7401518C70E00E13FB8 /* Project object */ = { 165 | isa = PBXProject; 166 | attributes = { 167 | CLASSPREFIX = MB; 168 | LastUpgradeCheck = 0700; 169 | ORGANIZATIONNAME = "Matej Bukovinski"; 170 | TargetAttributes = { 171 | 1D104D791ACA36CC00973364 = { 172 | CreatedOnToolsVersion = 6.2; 173 | }; 174 | }; 175 | }; 176 | buildConfigurationList = D286A7431518C70E00E13FB8 /* Build configuration list for PBXProject "MBProgressHUD" */; 177 | compatibilityVersion = "Xcode 3.2"; 178 | developmentRegion = English; 179 | hasScannedForEncodings = 0; 180 | knownRegions = ( 181 | en, 182 | ); 183 | mainGroup = D286A73E1518C70E00E13FB8; 184 | productRefGroup = D286A74A1518C70F00E13FB8 /* Products */; 185 | projectDirPath = ""; 186 | projectRoot = ""; 187 | targets = ( 188 | D286A7481518C70F00E13FB8 /* MBProgressHUD Static Library */, 189 | 1D104D791ACA36CC00973364 /* MBProgressHUD Framework */, 190 | ); 191 | }; 192 | /* End PBXProject section */ 193 | 194 | /* Begin PBXResourcesBuildPhase section */ 195 | 1D104D781ACA36CC00973364 /* Resources */ = { 196 | isa = PBXResourcesBuildPhase; 197 | buildActionMask = 2147483647; 198 | files = ( 199 | ); 200 | runOnlyForDeploymentPostprocessing = 0; 201 | }; 202 | /* End PBXResourcesBuildPhase section */ 203 | 204 | /* Begin PBXSourcesBuildPhase section */ 205 | 1D104D751ACA36CC00973364 /* Sources */ = { 206 | isa = PBXSourcesBuildPhase; 207 | buildActionMask = 2147483647; 208 | files = ( 209 | 1D104D931ACA371400973364 /* MBProgressHUD.m in Sources */, 210 | ); 211 | runOnlyForDeploymentPostprocessing = 0; 212 | }; 213 | D286A7451518C70F00E13FB8 /* Sources */ = { 214 | isa = PBXSourcesBuildPhase; 215 | buildActionMask = 2147483647; 216 | files = ( 217 | D286A7531518C70F00E13FB8 /* MBProgressHUD.m in Sources */, 218 | ); 219 | runOnlyForDeploymentPostprocessing = 0; 220 | }; 221 | /* End PBXSourcesBuildPhase section */ 222 | 223 | /* Begin XCBuildConfiguration section */ 224 | 1D104D8E1ACA36CC00973364 /* Debug */ = { 225 | isa = XCBuildConfiguration; 226 | buildSettings = { 227 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 228 | CLANG_ENABLE_MODULES = YES; 229 | CLANG_ENABLE_OBJC_ARC = YES; 230 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 231 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 232 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 233 | CURRENT_PROJECT_VERSION = 1; 234 | DEFINES_MODULE = YES; 235 | DYLIB_COMPATIBILITY_VERSION = 1; 236 | DYLIB_CURRENT_VERSION = 1; 237 | DYLIB_INSTALL_NAME_BASE = "@rpath"; 238 | GCC_PREPROCESSOR_DEFINITIONS = ( 239 | "DEBUG=1", 240 | "$(inherited)", 241 | ); 242 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 243 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 244 | INFOPLIST_FILE = "Framework-Info.plist"; 245 | INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; 246 | IPHONEOS_DEPLOYMENT_TARGET = 8.2; 247 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 248 | MTL_ENABLE_DEBUG_INFO = YES; 249 | PRODUCT_BUNDLE_IDENTIFIER = "com.matej.$(PRODUCT_NAME:rfc1034identifier)"; 250 | PRODUCT_NAME = MBProgressHUD; 251 | SKIP_INSTALL = YES; 252 | TARGETED_DEVICE_FAMILY = "1,2"; 253 | VERSIONING_SYSTEM = "apple-generic"; 254 | VERSION_INFO_PREFIX = ""; 255 | }; 256 | name = Debug; 257 | }; 258 | 1D104D8F1ACA36CC00973364 /* Release */ = { 259 | isa = XCBuildConfiguration; 260 | buildSettings = { 261 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 262 | CLANG_ENABLE_MODULES = YES; 263 | CLANG_ENABLE_OBJC_ARC = YES; 264 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 265 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 266 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 267 | COPY_PHASE_STRIP = NO; 268 | CURRENT_PROJECT_VERSION = 1; 269 | DEFINES_MODULE = YES; 270 | DYLIB_COMPATIBILITY_VERSION = 1; 271 | DYLIB_CURRENT_VERSION = 1; 272 | DYLIB_INSTALL_NAME_BASE = "@rpath"; 273 | ENABLE_NS_ASSERTIONS = NO; 274 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 275 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 276 | INFOPLIST_FILE = "Framework-Info.plist"; 277 | INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; 278 | IPHONEOS_DEPLOYMENT_TARGET = 8.2; 279 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 280 | MTL_ENABLE_DEBUG_INFO = NO; 281 | PRODUCT_BUNDLE_IDENTIFIER = "com.matej.$(PRODUCT_NAME:rfc1034identifier)"; 282 | PRODUCT_NAME = MBProgressHUD; 283 | SKIP_INSTALL = YES; 284 | TARGETED_DEVICE_FAMILY = "1,2"; 285 | VERSIONING_SYSTEM = "apple-generic"; 286 | VERSION_INFO_PREFIX = ""; 287 | }; 288 | name = Release; 289 | }; 290 | D286A7541518C70F00E13FB8 /* Debug */ = { 291 | isa = XCBuildConfiguration; 292 | buildSettings = { 293 | ALWAYS_SEARCH_USER_PATHS = NO; 294 | CLANG_CXX_LANGUAGE_STANDARD = "c++0x"; 295 | CLANG_CXX_LIBRARY = "libc++"; 296 | CLANG_ENABLE_OBJC_ARC = YES; 297 | CLANG_WARN_BOOL_CONVERSION = YES; 298 | CLANG_WARN_CONSTANT_CONVERSION = YES; 299 | CLANG_WARN_EMPTY_BODY = YES; 300 | CLANG_WARN_ENUM_CONVERSION = YES; 301 | CLANG_WARN_INT_CONVERSION = YES; 302 | CLANG_WARN_UNREACHABLE_CODE = YES; 303 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 304 | COPY_PHASE_STRIP = NO; 305 | ENABLE_STRICT_OBJC_MSGSEND = YES; 306 | ENABLE_TESTABILITY = YES; 307 | GCC_C_LANGUAGE_STANDARD = gnu99; 308 | GCC_DYNAMIC_NO_PIC = NO; 309 | GCC_NO_COMMON_BLOCKS = YES; 310 | GCC_OPTIMIZATION_LEVEL = 0; 311 | GCC_PREPROCESSOR_DEFINITIONS = ( 312 | "DEBUG=1", 313 | "$(inherited)", 314 | ); 315 | GCC_SYMBOLS_PRIVATE_EXTERN = NO; 316 | GCC_VERSION = com.apple.compilers.llvm.clang.1_0; 317 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 318 | GCC_WARN_ABOUT_RETURN_TYPE = YES; 319 | GCC_WARN_UNDECLARED_SELECTOR = YES; 320 | GCC_WARN_UNINITIALIZED_AUTOS = YES; 321 | GCC_WARN_UNUSED_FUNCTION = YES; 322 | GCC_WARN_UNUSED_VARIABLE = YES; 323 | IPHONEOS_DEPLOYMENT_TARGET = 6.0; 324 | ONLY_ACTIVE_ARCH = YES; 325 | SDKROOT = iphoneos; 326 | }; 327 | name = Debug; 328 | }; 329 | D286A7551518C70F00E13FB8 /* Release */ = { 330 | isa = XCBuildConfiguration; 331 | buildSettings = { 332 | ALWAYS_SEARCH_USER_PATHS = NO; 333 | CLANG_CXX_LANGUAGE_STANDARD = "c++0x"; 334 | CLANG_CXX_LIBRARY = "libc++"; 335 | CLANG_ENABLE_OBJC_ARC = YES; 336 | CLANG_WARN_BOOL_CONVERSION = YES; 337 | CLANG_WARN_CONSTANT_CONVERSION = YES; 338 | CLANG_WARN_EMPTY_BODY = YES; 339 | CLANG_WARN_ENUM_CONVERSION = YES; 340 | CLANG_WARN_INT_CONVERSION = YES; 341 | CLANG_WARN_UNREACHABLE_CODE = YES; 342 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 343 | COPY_PHASE_STRIP = YES; 344 | ENABLE_STRICT_OBJC_MSGSEND = YES; 345 | GCC_C_LANGUAGE_STANDARD = gnu99; 346 | GCC_NO_COMMON_BLOCKS = YES; 347 | GCC_VERSION = com.apple.compilers.llvm.clang.1_0; 348 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 349 | GCC_WARN_ABOUT_RETURN_TYPE = YES; 350 | GCC_WARN_UNDECLARED_SELECTOR = YES; 351 | GCC_WARN_UNINITIALIZED_AUTOS = YES; 352 | GCC_WARN_UNUSED_FUNCTION = YES; 353 | GCC_WARN_UNUSED_VARIABLE = YES; 354 | IPHONEOS_DEPLOYMENT_TARGET = 6.0; 355 | SDKROOT = iphoneos; 356 | VALIDATE_PRODUCT = YES; 357 | }; 358 | name = Release; 359 | }; 360 | D286A7571518C70F00E13FB8 /* Debug */ = { 361 | isa = XCBuildConfiguration; 362 | buildSettings = { 363 | DSTROOT = /tmp/MBProgressHUD.dst; 364 | GCC_PRECOMPILE_PREFIX_HEADER = YES; 365 | GCC_PREFIX_HEADER = "MBProgressHUD-Prefix.pch"; 366 | OTHER_LDFLAGS = "-ObjC"; 367 | PRODUCT_NAME = MBProgressHUD; 368 | SKIP_INSTALL = YES; 369 | }; 370 | name = Debug; 371 | }; 372 | D286A7581518C70F00E13FB8 /* Release */ = { 373 | isa = XCBuildConfiguration; 374 | buildSettings = { 375 | DSTROOT = /tmp/MBProgressHUD.dst; 376 | GCC_PRECOMPILE_PREFIX_HEADER = YES; 377 | GCC_PREFIX_HEADER = "MBProgressHUD-Prefix.pch"; 378 | OTHER_LDFLAGS = "-ObjC"; 379 | PRODUCT_NAME = MBProgressHUD; 380 | SKIP_INSTALL = YES; 381 | }; 382 | name = Release; 383 | }; 384 | /* End XCBuildConfiguration section */ 385 | 386 | /* Begin XCConfigurationList section */ 387 | 1D104D8D1ACA36CC00973364 /* Build configuration list for PBXNativeTarget "MBProgressHUD Framework" */ = { 388 | isa = XCConfigurationList; 389 | buildConfigurations = ( 390 | 1D104D8E1ACA36CC00973364 /* Debug */, 391 | 1D104D8F1ACA36CC00973364 /* Release */, 392 | ); 393 | defaultConfigurationIsVisible = 0; 394 | defaultConfigurationName = Release; 395 | }; 396 | D286A7431518C70E00E13FB8 /* Build configuration list for PBXProject "MBProgressHUD" */ = { 397 | isa = XCConfigurationList; 398 | buildConfigurations = ( 399 | D286A7541518C70F00E13FB8 /* Debug */, 400 | D286A7551518C70F00E13FB8 /* Release */, 401 | ); 402 | defaultConfigurationIsVisible = 0; 403 | defaultConfigurationName = Release; 404 | }; 405 | D286A7561518C70F00E13FB8 /* Build configuration list for PBXNativeTarget "MBProgressHUD Static Library" */ = { 406 | isa = XCConfigurationList; 407 | buildConfigurations = ( 408 | D286A7571518C70F00E13FB8 /* Debug */, 409 | D286A7581518C70F00E13FB8 /* Release */, 410 | ); 411 | defaultConfigurationIsVisible = 0; 412 | defaultConfigurationName = Release; 413 | }; 414 | /* End XCConfigurationList section */ 415 | }; 416 | rootObject = D286A7401518C70E00E13FB8 /* Project object */; 417 | } 418 | -------------------------------------------------------------------------------- /MBProgressHUD.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /MBProgressHUD.xcodeproj/xcshareddata/xcschemes/MBProgressHUD Framework.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 34 | 35 | 45 | 46 | 52 | 53 | 54 | 55 | 56 | 57 | 63 | 64 | 70 | 71 | 72 | 73 | 75 | 76 | 79 | 80 | 81 | -------------------------------------------------------------------------------- /MBProgressHUD.xcodeproj/xcshareddata/xcschemes/MBProgressHUD.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 34 | 35 | 45 | 46 | 52 | 53 | 54 | 55 | 56 | 57 | 63 | 64 | 66 | 67 | 70 | 71 | 72 | -------------------------------------------------------------------------------- /MBProgressHUD.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 9 | 10 | 12 | 13 | 15 | 16 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /README.mdown: -------------------------------------------------------------------------------- 1 | # MBProgressHUD 2 | 3 | [![Build Status](https://travis-ci.org/matej/MBProgressHUD.svg?branch=master)](https://travis-ci.org/matej/MBProgressHUD) [![codecov.io](https://codecov.io/github/matej/MBProgressHUD/coverage.svg?branch=master)](https://codecov.io/github/matej/MBProgressHUD?branch=master) 4 | [![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage#adding-frameworks-to-an-application) [![CocoaPods compatible](https://img.shields.io/cocoapods/v/MBProgressHUD.svg?style=flat)](https://cocoapods.org/pods/MBProgressHUD) [![License: MIT](https://img.shields.io/cocoapods/l/MBProgressHUD.svg?style=flat)](http://opensource.org/licenses/MIT) 5 | 6 | `MBProgressHUD` is an iOS drop-in class that displays a translucent HUD with an indicator and/or labels while work is being done in a background thread. The HUD is meant as a replacement for the undocumented, private `UIKit` `UIProgressHUD` with some additional features. 7 | 8 | [![](http://dl.dropbox.com/u/378729/MBProgressHUD/v1/1-thumb.png)](http://dl.dropbox.com/u/378729/MBProgressHUD/v1/1.png) 9 | [![](http://dl.dropbox.com/u/378729/MBProgressHUD/v1/2-thumb.png)](http://dl.dropbox.com/u/378729/MBProgressHUD/v1/2.png) 10 | [![](http://dl.dropbox.com/u/378729/MBProgressHUD/v1/3-thumb.png)](http://dl.dropbox.com/u/378729/MBProgressHUD/v1/3.png) 11 | [![](http://dl.dropbox.com/u/378729/MBProgressHUD/v1/4-thumb.png)](http://dl.dropbox.com/u/378729/MBProgressHUD/v1/4.png) 12 | [![](http://dl.dropbox.com/u/378729/MBProgressHUD/v1/5-thumb.png)](http://dl.dropbox.com/u/378729/MBProgressHUD/v1/5.png) 13 | [![](http://dl.dropbox.com/u/378729/MBProgressHUD/v1/6-thumb.png)](http://dl.dropbox.com/u/378729/MBProgressHUD/v1/6.png) 14 | [![](http://dl.dropbox.com/u/378729/MBProgressHUD/v1/7-thumb.png)](http://dl.dropbox.com/u/378729/MBProgressHUD/v1/7.png) 15 | 16 | **NOTE:** The class has recently undegone a major rewrite. The old version is available in the [legacy](https://github.com/jdg/MBProgressHUD/tree/legacy) branch, should you need it. 17 | 18 | ## Requirements 19 | 20 | `MBProgressHUD` works on iOS 6+ and requires ARC to build. It depends on the following Apple frameworks, which should already be included with most Xcode templates: 21 | 22 | * Foundation.framework 23 | * UIKit.framework 24 | * CoreGraphics.framework 25 | 26 | You will need the latest developer tools in order to build `MBProgressHUD`. Old Xcode versions might work, but compatibility will not be explicitly maintained. 27 | 28 | ## Adding MBProgressHUD to your project 29 | 30 | ### CocoaPods 31 | 32 | [CocoaPods](http://cocoapods.org) is the recommended way to add MBProgressHUD to your project. 33 | 34 | 1. Add a pod entry for MBProgressHUD to your Podfile `pod 'MBProgressHUD', '~> 0.9.2'` 35 | 2. Install the pod(s) by running `pod install`. 36 | 3. Include MBProgressHUD wherever you need it with `#import "MBProgressHUD.h"`. 37 | 38 | ### Carthage 39 | 40 | 1. Add MBProgressHUD to your Cartfile. e.g., `github "jdg/MBProgressHUD" ~> 0.9.2` 41 | 2. Run `carthage update` 42 | 3. Follow the rest of the [standard Carthage installation instructions](https://github.com/Carthage/Carthage#adding-frameworks-to-an-application) to add MBProgressHUD to your project. 43 | 44 | ### Source files 45 | 46 | Alternatively you can directly add the `MBProgressHUD.h` and `MBProgressHUD.m` source files to your project. 47 | 48 | 1. Download the [latest code version](https://github.com/matej/MBProgressHUD/archive/master.zip) or add the repository as a git submodule to your git-tracked project. 49 | 2. Open your project in Xcode, then drag and drop `MBProgressHUD.h` and `MBProgressHUD.m` onto your project (use the "Product Navigator view"). Make sure to select Copy items when asked if you extracted the code archive outside of your project. 50 | 3. Include MBProgressHUD wherever you need it with `#import "MBProgressHUD.h"`. 51 | 52 | ### Static library 53 | 54 | You can also add MBProgressHUD as a static library to your project or workspace. 55 | 56 | 1. Download the [latest code version](https://github.com/matej/MBProgressHUD/downloads) or add the repository as a git submodule to your git-tracked project. 57 | 2. Open your project in Xcode, then drag and drop `MBProgressHUD.xcodeproj` onto your project or workspace (use the "Product Navigator view"). 58 | 3. Select your target and go to the Build phases tab. In the Link Binary With Libraries section select the add button. On the sheet find and add `libMBProgressHUD.a`. You might also need to add `MBProgressHUD` to the Target Dependencies list. 59 | 4. Include MBProgressHUD wherever you need it with `#import `. 60 | 61 | ## Usage 62 | 63 | The main guideline you need to follow when dealing with MBProgressHUD while running long-running tasks is keeping the main thread work-free, so the UI can be updated promptly. The recommended way of using MBProgressHUD is therefore to set it up on the main thread and then spinning the task, that you want to perform, off onto a new thread. 64 | 65 | ```objective-c 66 | [MBProgressHUD showHUDAddedTo:self.view animated:YES]; 67 | dispatch_async(dispatch_get_global_queue( DISPATCH_QUEUE_PRIORITY_LOW, 0), ^{ 68 | // Do something... 69 | dispatch_async(dispatch_get_main_queue(), ^{ 70 | [MBProgressHUD hideHUDForView:self.view animated:YES]; 71 | }); 72 | }); 73 | ``` 74 | 75 | If you need to configure the HUD you can do this by using the MBProgressHUD reference that showHUDAddedTo:animated: returns. 76 | 77 | ```objective-c 78 | MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:self.view animated:YES]; 79 | hud.mode = MBProgressHUDModeAnnularDeterminate; 80 | hud.labelText = @"Loading"; 81 | [self doSomethingInBackgroundWithProgressCallback:^(float progress) { 82 | hud.progress = progress; 83 | } completionCallback:^{ 84 | [hud hide:YES]; 85 | }]; 86 | ``` 87 | 88 | UI updates should always be done on the main thread. Some MBProgressHUD setters are however considered "thread safe" and can be called from background threads. Those also include `setMode:`, `setCustomView:`, `setLabelText:`, `setLabelFont:`, `setDetailsLabelText:`, `setDetailsLabelFont:` and `setProgress:`. 89 | 90 | If you need to run your long-running task in the main thread, you should perform it with a slight delay, so UIKit will have enough time to update the UI (i.e., draw the HUD) before you block the main thread with your task. 91 | 92 | ```objective-c 93 | [MBProgressHUD showHUDAddedTo:self.view animated:YES]; 94 | dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, 0.01 * NSEC_PER_SEC); 95 | dispatch_after(popTime, dispatch_get_main_queue(), ^(void){ 96 | // Do something... 97 | [MBProgressHUD hideHUDForView:self.view animated:YES]; 98 | }); 99 | ``` 100 | 101 | You should be aware that any HUD updates issued inside the above block won't be displayed until the block completes. 102 | 103 | For more examples, including how to use MBProgressHUD with asynchronous operations such as NSURLConnection, take a look at the bundled demo project. Extensive API documentation is provided in the header file (MBProgressHUD.h). 104 | 105 | 106 | ## License 107 | 108 | This code is distributed under the terms and conditions of the [MIT license](LICENSE). 109 | 110 | ## Change-log 111 | 112 | A brief summary of each MBProgressHUD release can be found in the [CHANGELOG](CHANGELOG.mdown). 113 | --------------------------------------------------------------------------------