Coder Social home page Coder Social logo

xnprogresshud's Introduction

XNProgressHUD

一个丝滑、灵活的HUD

hud-01.gif hud-02.gif hud-03.gif hud-04.gif

一款支持各种自定义的轻量级HUD,支持垂直、水平两种样式。XNProgressHUD非常灵活,所见的部分都可根据自己的要求进行自定义,包括自义动画效果或图片,只需要实现相关协议方法。

安装使用

 pod 'XNProgressHUD'

使用说明

// 设置显示位置
[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];

在UIWindow上显示:

[XNHUD showLoadingWithTitle:@"正在登录"];
[XNHUD showWithTitle:@"这是一个支持自定义的轻量级HUD"];
[XNHUD showInfoWithTitle:@"邮箱地址不能为空"];
[XNHUD showErrorWithTitle:@"拒绝访问"];
[XNHUD showSuccessWithTitle:@"操作成功"];

在UIViewController上显示(maskType.enable=true时,导航栏依然可以接受点击事件)

// 引入'UIViewController+XNProgressHUD.h'
[self.hud showLoadingWithTitle:@"正在登录"];
[self.hud showWithTitle:@"这是一个支持自定义的轻量级HUD"];
[self.hud showInfoWithTitle:@"邮箱地址不能为空"];
[self.hud showErrorWithTitle:@"拒绝访问"];
[self.hud showSuccessWithTitle:@"操作成功"];

在UIView上显示

UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 300, 300)];
[self.view addSubview:view];
// 设置显示的目标View并传入显示位置
[XNHUD setTargetView:view position:CGPointMake(view.bounds.size.width/2,  view.bounds.size.height/2)];
[XNHUD showLoadingWithTitle:@"指定显示在某个View上"];

属性和方法说明

显示时长minimumDelayDismissDuration作用于非加载样式的视图:XNAnimationViewStyleInfoImage、XNAnimationViewStyleError、XNAnimationViewStyleSuccess; 显示时长maximumDelayDismissDuration作用与加载样式的视图:XNAnimationViewStyleLoading、XNAnimationViewStyleProgress

@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

你可以自定义某一个状态下的动画,步骤非常简单,喜欢XNAnimationView中相应的Layer就行了,如果你想替换所有状态下的动画,请重写XNAnimationView。

这里就介绍这么多,其他功能自行探索。

GitHub地址

https://github.com/LuohanCC/XNProgressHUD

如果你觉得不错,请给我Star ★★★★★★★★★★ 给我Star吧

xnprogresshud's People

Contributors

luohancc avatar maskedman2020 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

xnprogresshud's Issues

支持最小宽度

非常感谢大力支持!谢谢!

在vertical的情况下,如果标题过于短,而自定义的图标和padding都比较大的话,就会显示成瘦的长方形。可否支持下最小宽度,让他看起来没那么扁?

流程问题

网络请求中习惯 [self.targetHud show];
结束后 [self.targetHud dismiss];
需要文字提示的时候showWithTitle
[self.targetHud show];
[self.targetHud dismiss];
[self.targetHud showWithTitle:@"这是一个支持自定义的轻量级HUD"];
这样的效果提示框会一闪而过,dismiss中有个animate延迟问题

setDisposableDelayResponse 马上dismiss后卡住

[[XNProgressHUD shared] setDisposableDelayResponse:0.3 delayDismiss:60];
[[XNProgressHUD shared] dismiss];
我想避免多次弹框问题,网络请求前延迟展示loading,请求后取消loading,如果0.3秒内返回了,就导致消失不掉的问题
被return了,里边玄虚弹出时候定时器处理也有点混乱

  • (void)didDismissOnMainQueue {
    BOOL showing = self.showing;

    __block UIView *targetView = self.targetView;
    if (!showing && [self isWindowAndIsNotKeyWindow:(targetView)]) {
    targetView.hidden = YES;
    }
    if(!showing) return;

状态的过渡动画问题

尝试如下操作:

            XNProgressHUD.shared()?.show()
            Async.main(after: 5) {
                XNProgressHUD.shared()?.showError(withTitle: "请求失败")
                Async.main(after: 5) {
                    XNProgressHUD.shared()?.showSuccess(withTitle: "请求成功")
                }
            }

在loading > error的过程中,titleLabel的动画是从左上角下来的,有点儿奇怪。

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.