iOS开发必备HUD(透明指示层)

iOS开发必备HUD(透明指示层)

字数421 阅读2123 评论1 

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

GitHub地址:https://github.com/scalessec/Toast
这个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中就更方便,等我完善了在放出来分享啦
原文地址:https://www.cnblogs.com/AlvinCrash/p/5379439.html