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
};
img_dfc4c06eca1ea3f1f87b7c9020470fdb.png
Loading效果
img_845fe4afd96ce35db0d810756aa711a2.png
还可以显示1行或2行文字
img_18c5367957288ca86e42b38045d02159.png
圆形进度圆
img_f9efc6b2aa1c0618ae412247efe7537d.png
条形进度条
img_c4965a8b002fe426c879eb060a6d9e8c.png
通过自定义图片形成的效果
img_b7e5bd00c1d5e4ebcdfdd3968bcc376d.png
可以只要文字提醒

2. SVProgressHUD

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

img_9d45829436ea7ec37346a171ea3840de.gif
效果图.gif

3. JGProgressHUD

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

img_cd211753f92fac35d784335a087ead36.png
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];
img_1eab7270d4007c6c89d32ec40a3ebdce.png
Toast部分效果
目前来说,以前4种HUD就能满足基本需求,实际开发中,集成到一个Utility中就更方便,等我完善了在放出来分享啦
  • 如果有什么疑问,可以在评论区一起讨论;
  • 如果有什么不正确的地方,欢迎指导!


注:本文首发于 iHTCboy's blog,如若转载,请注明来源。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
XNProgressHUD (https://github.com/LuohanCC/XNProgressHUD) 一款支持支持自定义的轻量级HUD,支持垂直、水平两种样式。SVProgressHUD非常灵活,所见的部分都可根据自己的要求进行自定义,包括自义动画效果或图片,只需要实现相关协议方法。 安装使用 pod 'XNProgressHUD' 使用说明 在Window上显示: [XNHUD showLoadingWithTitle:@"正在登录"]; [XNHUD showWithTitle:@"这是一个支持自定义的轻量级HUD"]; [XNHUD showInfoWithTitle:@"邮箱地址不能为空"]; [XNHUD showErrorWithTitle:@"拒绝访问"]; [XNHUD showSuccessWithTitle:@"操作成功"]; 在ViewController上显示(maskType.enable=true时,导航栏依然可以接受点击事件) // 引入'UIViewController XNProgressHUD.h' [self.hud showLoadingWithTitle:@"正在登录"]; [self.hud showWithTitle:@"这是一个支持自定义的轻量级HUD"]; [self.hud showInfoWithTitle:@"邮箱地址不能为空"]; [self.hud showErrorWithTitle:@"拒绝访问"]; [self.hud showSuccessWithTitle:@"操作成功"]; // 设置显示位置 [XNHUD setPosition:CGPointMake(self.view.bounds.size.width/2, self.view.bounds.size.height * 0.7)]; // 设置主色调 [XNHUD setTintColor:[UIColor colorWithRed:38/255.0 green:50/255.0 blue:56/255.0 alpha:0.8]]; // 设置相应的maskType转态下的颜色(16进制颜色值) [XNHUD setMaskType:(XNProgressHUDMaskTypeBlack) hexColor:0x00000044]; [XNHUD setMaskType:(XNProgressHUDMaskTypeCustom) hexColor:0xff000044]; 属性和方法说明 显示时长minimumDelayDismissDuration作用于非加载样式的视图:XNRefreshViewStyleInfoImage、XNRefreshViewStyleError、XNRefreshViewStyleSuccess; 显示时长maximumDelayDismissDuration作用与加载样式的视图:XNRefreshViewStyleLoading、XNRefreshViewStyleProgress。 @property (nonatomic, assign) NSTimeInterval minimumDelayDismissDuration; //default:1.5f @property (nonatomic, assign) NSTimeInterval maximumDelayDismissDuration; //default:20.f 延时显示时间和延时消失时间,该方法只对下一次HUD显示生效(只生效一次)。 [XNHUD setDisposableDelayResponse:1.0f delayDismiss:2.0f]; 设置排列方向,默认为水平方向 [XNHUD setOrientation:XNProgressHUDOrientationHorizontal]; 自定义XNProgressHUD 如果需要自定义加载视图的显示内容和动画样式,请重写XNRefreshView并实现XNRefreshViewProtocol中的协议方法即可,具体如下 1.自定义XNRefreshView并实现XNRefreshViewProtocol中的协议方法; 2.继承XNProgressHUD并实现XNProgressHUDMethod中的协议方法。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值