• IOS 加载中提示框


    LoadingView.h
    #import <Foundation/Foundation.h>
    @class MBProgressHUD;
    
    @interface LoadingView : NSObject
    
    @property (nonatomic, retain) MBProgressHUD *HUD;
    
    + (LoadingView *)sharedInstance;
    
    /**
     *  加载中提示框
     *
     *  @param title     标题
     *  @param superView 父View
     */
    - (void)showLoadingViewWithTitle:(NSString *)title superView:(UIView *)superView;
    
    /**
     *  加载中提示框
     *
     *  @param title     标题
     *  @param delay     关闭时间
     *  @param superView 父View
     */
    - (void)showLoadingViewWithTitle:(NSString *)title afterDelay:(NSTimeInterval)delay superView:(UIView *)superView;
    
    /**
     *  关闭提示框
     */
    - (void)closeLoadingView;
    
    @end
    
    LoadingView.m
    #import "LoadingView.h"
    #import "MBProgressHUD.h"
    
    @implementation LoadingView
    
    @synthesize HUD;
    
    static LoadingView *_shardLoadingView = nil;
    
    + (LoadingView *)sharedInstance
    {
        if (_shardLoadingView == nil) {
            _shardLoadingView = [[LoadingView alloc]init];
        }
        return _shardLoadingView;
    }
    
    - (id)init
    {
        self = [super init];
        if (self) {
             HUD = [[MBProgressHUD alloc] init];
        }
        return self;
    }
    
    - (void)showLoadingViewWithTitle:(NSString *)title superView:(UIView *)superView
    {
        HUD.labelText = title;
        [superView addSubview:HUD];
        [superView bringSubviewToFront:HUD];
        [HUD show:YES];
        
    }
    
    - (void)showLoadingViewWithTitle:(NSString *)title afterDelay:(NSTimeInterval)delay superView:(UIView *)superView
    {
        HUD.labelText = title;
        [superView addSubview:HUD];
        [superView bringSubviewToFront:HUD];
        [HUD show:YES];
        
        [HUD hide:YES afterDelay:delay];
    }
    
    - (void)closeLoadingView
    {
        [HUD hide:YES];
    }
    
    @end
    
    // 使用
     [[LoadingView sharedInstance]showLoadingViewWithTitle:@"加载中...." superView:self.view];

  • 相关阅读:
    【转载】C++指针随想
    微信小程序实现电子签名
    js数组常用方法
    css文本两端对齐
    js判断某个数组中是否包含另一个数组
    react 限制小数点位数
    原生js 操作class 原生js获取父元素
    转发: JS中的call()和apply()方法和区别 --小白变色记
    fail2Ban ubuntu
    VSCode 搭建 Vue项目 lite-server
  • 原文地址:https://www.cnblogs.com/joesen/p/3584754.html
Copyright © 2020-2023  润新知