1. 程式人生 > >iOS開發必備HUD(透明指示層)

iOS開發必備HUD(透明指示層)

1.MBProgressHUD

GitHub地址:https://github.com/jdg/MBProgressHUD
基本上看到的主流iOS應用都集成了這個,Star 7k了,最近看到很多應用HUD隱藏時,有一個動畫過程,我還以為是自己擴充套件的,後來研究才發現,有這個屬性animationType:

@property (assign) MBProgressHUDAnimation animationType;
typedef NS_ENUM(NSInteger, MBProgressHUDAnimation) {
    /** Opacity animation */
    MBProgressHUDAnimationFade,
    /** Opacity + scale animation */
MBProgressHUDAnimationZoom, MBProgressHUDAnimationZoomOut = MBProgressHUDAnimationZoom, MBProgressHUDAnimationZoomIn };
Loading效果
Loading效果 還可以顯示1行或2行文字
還可以顯示1行或2行文字 圓形進度圓
圓形進度圓 條形進度條
條形進度條 通過自定義圖片形成的效果
通過自定義圖片形成的效果 可以只要文字提醒
可以只要文字提醒

2. SVProgressHUD

GitHub地址:https://github.com/TransitApp/SVProgressHUD
SVProgressHUD和MBProgressHUD效果差不多,特點就是不需要使用協議,同時也不需要宣告例項。直接通過類方法就可以呼叫:
[SVProgressHUD method]


[SVProgressHUD dismiss]

效果圖.gif
效果圖.gif

3. JGProgressHUD

GitHub地址:https://github.com/JonasGessner/JGProgressHUD
JGProgressHUD和MBProgressHUD效果差不多,作為後起之秀,特點就是如果有鍵盤時,HUD可以自動上移,效果非常棒!另外自定義定製也很靈活。

JGProgressHUD效果圖
JGProgressHUD效果圖

4. Toast

// basic usage
[self.view makeToast:@"This is a piece of toast."];

// toast with duration, title, and position
[self.view makeToast:@"This is a piece of toast with a title." duration:3.0 position:CSToastPositionTop title:@"Toast Title"]; // toast with an image [self.view makeToast:@"This is a piece of toast with an image." duration:3.0 position:[NSValue valueWithCGPoint:CGPointMake(110, 110)] image:[UIImage imageNamed:@"toast.png"]]; // display toast with an activity spinner [self.view makeToastActivity];
Toast部分效果
Toast部分效果
目前來說,以前4種HUD就能滿足基本需求,實際開發中,整合到一個Utility中就更方便,等我完善了在放出來分享啦