JGProgressHUD

https://github.com/JonasGessner/JGProgressHUD

JGProgressHUD是HUD(head up Display)中的一种,虽然它在Github上的star不是做多的,但是它功能应该是最花哨的,我比较喜欢~~ 毕竟可以装逼

安装

CocoaPods:

把下面这行写进Podfile:

1
pod 'JGProgressHUD'

Carthage:

把下面这行写进Cartfile:

1
github "JonasGessner/JGProgressHUD" >= 1.3.1

Framework (iOS >= 8.0 only):

  1. JGProgressHUD.xcodeproj拖入工程文件。
  2. JGProgressHUD.framework 加到工程的General->Embedded Binaries中。
  3. Build Settings->Other Linker Flags中加入-ObjC flag

使用

首先要“import”头文件

Objective-C:

1
#import "JGProgressHUD.h"

swift:

1
import JGProgressHUD

模糊进度显示(其实就是一朵菊花)

1
2
3
4
JGProgressHUD *HUD = [JGProgressHUD progressHUDWithStyle:JGProgressHUDStyleDark];
HUD.textLabel.text = @"Loading";
[HUD showInView:self.view];
[HUD dismissAfterDelay:3.0];

错误显示

1
2
3
4
5
JGProgressHUD *HUD = [JGProgressHUD progressHUDWithStyle:JGProgressHUDStyleDark];
HUD.textLabel.text = @"Error";
HUD.indicatorView = [[JGProgressHUDErrorIndicatorView alloc] init]; //JGProgressHUDSuccessIndicatorView is also available
[HUD showInView:self.view];
[HUD dismissAfterDelay:3.0];

自定义图片显示

1
2
3
4
JGProgressHUD *HUD = [JGProgressHUD progressHUDWithStyle:JGProgressHUDStyleDark];
HUD.indicatorView = [[JGProgressHUDImageIndicatorView alloc] initWithImage:[UIImage imageNamed:@"my_image.png"]];
[HUD showInView:self.view];
[HUD dismissAfterDelay:3.0];

有进度显示

1
2
3
4
5
6

JGProgressHUD *HUD = [JGProgressHUD progressHUDWithStyle:JGProgressHUDStyleDark];
HUD.indicatorView = [[JGProgressHUDPieIndicatorView alloc] initWithHUDStyle:HUD.style]; //Or JGProgressHUDRingIndicatorView
[HUD showInView:self.view];
[HUD dismissAfterDelay:3.0];

效果图