iOS开发必备HUD(透明指示层)
2015-05-10 本文已影响18879人
iHTCboy
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
};






2. SVProgressHUD
GitHub地址:https://github.com/TransitApp/SVProgressHUD
SVProgressHUD和MBProgressHUD效果差不多,特点就是不需要使用协议,同时也不需要声明实例。直接通过类方法就可以调用:
[SVProgressHUD method]
[SVProgressHUD dismiss]

3. JGProgressHUD
GitHub地址:https://github.com/JonasGessner/JGProgressHUD
JGProgressHUD和MBProgressHUD效果差不多,作为后起之秀,特点就是如果有键盘时,HUD可以自动上移,效果非常棒!另外自定义定制也很灵活。

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];

目前来说,以前4种HUD就能满足基本需求,实际开发中,集成到一个Utility中就更方便,等我完善了在放出来分享啦
- 如果有什么疑问,可以在评论区一起讨论;
- 如果有什么不正确的地方,欢迎指导!
注:本文首发于 iHTCboy's blog,如若转载,请注明来源。