zoukankan      html  css  js  c++  java
  • 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];

  • 相关阅读:
    洛谷P2602 [ZJOI2010]数字计数 题解
    数位DP模板
    The Meaningless Game 思维题
    CF55D Beautiful numbers 数位DP
    NOIP 2016 洛谷 P2827 蚯蚓 题解
    弹性碰撞问题:Ants+Linear world
    BZOJ1294 洛谷P2566 状态压缩DP 围豆豆
    朋友HDU
    树的深度———树形DP
    CF1292C Xenon's Attack on the Gangs 题解
  • 原文地址:https://www.cnblogs.com/joesen/p/3584754.html
Copyright © 2011-2022 走看看