//

//  LoadingView.h

//  蓝桥播报

//

//  Created by 小小建 on 15/7/10.

//  Copyright (c) 2015年 蓝桥. All rights reserved.

//

#import <Foundation/Foundation.h>

#import <UIKit/UIKit.h>

@interface LoadingView : NSObject

{

UIView *_backGroundView;

UIView *_centerLoadingView;

UIActivityIndicatorView *_activityView;

}

+(LoadingView *)shareLoadingView;

-(void)show;

-(void)hide;

@end

//

//  LoadingView.m

//  蓝桥播报

//

//  Created by 小小建 on 15/7/10.

//  Copyright (c) 2015年 蓝桥. All rights reserved.

//

#import "LoadingView.h"

#import "AppDelegate.h"

static LoadingView *singleInstance=nil;

@implementation LoadingView

+(LoadingView *)shareLoadingView{

@synchronized(self){

if (singleInstance==nil) {

singleInstance=[[self alloc] init];

}

}

return singleInstance;

}

-(void)show{

AppDelegate *delegate=(AppDelegate *)[UIApplication sharedApplication].delegate;

_backGroundView=[[UIView alloc] initWithFrame:[UIScreen mainScreen].bounds];

[_backGroundView setBackgroundColor:[UIColor blackColor]];

_backGroundView.alpha=0.6;

[delegate.window addSubview:_backGroundView];

_centerLoadingView=[[UIView alloc] initWithFrame:CGRectMake(0, 0, 150, 150)];

_centerLoadingView.center=CGPointMake([UIScreen mainScreen].bounds.size.width/2, [UIScreen mainScreen].bounds.size.height/2);

UIImageView *imgView=[[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 150, 150)];

[imgView setImage:[UIImage imageNamed:@"loading_bg.png"]];

_activityView = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];

_activityView.center = CGPointMake(imgView.frame.size.width/2, imgView.frame.size.height/2-20);

_activityView.hidesWhenStopped = YES;

[_activityView startAnimating];

[imgView addSubview:_activityView];

UILabel *labelInfo = [[UILabel alloc] initWithFrame:CGRectMake(0,0, 140, 60)];

labelInfo.center=CGPointMake(imgView.frame.size.width/2, imgView.frame.size.height/2+20);

labelInfo.numberOfLines = 2;

labelInfo.backgroundColor = [UIColor clearColor];

labelInfo.textAlignment = NSTextAlignmentCenter;

labelInfo.textColor = [UIColor whiteColor];

labelInfo.font = [UIFont systemFontOfSize:16];

labelInfo.text=@"加载中...";

[imgView addSubview:labelInfo];

[_centerLoadingView addSubview:imgView];

[delegate.window addSubview:_centerLoadingView];

}

-(void)hide{

[_activityView stopAnimating];

[_centerLoadingView removeFromSuperview];

[_backGroundView removeFromSuperview];

}

@end

LoadingView的更多相关文章

  1. Android showing LoadingView or EmptyView for Activity or Fragment

    这几天利用一些时间,整理了一下,写了一个简单的工具类,用来快速的显示LoadingView或者EmptyView,以前都是定义一个layout,根布局为FrameLayout,再在layout布局文件 ...

  2. LoadingView 自定义加载图片

    #import <UIKit/UIKit.h> @interface LoadingView : UIView @property (nonatomic,strong) NSMutable ...

  3. Android 自定义通用的loadingview

    介绍 好久没有写博客啦,最近在接近新年了,年前的工作都要收尾,所以特别忙,周末抽空写了个通用的加载view,写篇博客分享出来. 功能 1.显示加载视图,加载失败的时候显示加载失败视图,数据为空时显示数 ...

  4. (Android自定义View)来来来,一起再撸一个Material风格loadingView。

    本文同步自博主的个人博客wing的地方酒馆 很久很久以前,撸了一款loadingview(点击这里回顾),当时觉得还不错,现在看看觉得好丑啊!!! 于是想再撸一个,无意间在这里看到一个很不错的效果,于 ...

  5. 手把手教你画一个 逼格满满圆形水波纹loadingview Android

    才没有完结呢o( ̄︶ ̄)n .大家好,这里是番外篇. 拜读了爱哥的博客,又学到不少东西.爱哥曾经说过: 要站在巨人的丁丁上. 那么今天,我们就站在爱哥的丁丁上来学习制作一款自定义view(开个玩笑,爱 ...

  6. 自定义控件---loadingView

    自定义加载框,效果如图: 这个loadingView可以在图片下添加文案(加载中...),还可以自定义动画效果,自定义布局文件,屏蔽用户操作,点击返回键后隐藏. 库类中包含了一个LoadingDial ...

  7. 三角函数之美-水波纹载入LoadingView

    一.前言 学习是要总结的.近期几天学习了画图相关的,可是使用的机会较少,如今又快要遗忘了,这次看了水波纹的绘制.认为十分有意思,还是 把实现的方法记录下来.技术无他,为手熟尔.还是要多练习,空淡误国, ...

  8. HarmonyOS三方件开发指南(15)-LoadingView功能介绍

    目录: 1. LoadingView组件功能介绍2. Lottie使用方法3. Lottie开发实现4.<HarmonyOS三方件开发指南>系列文章合集 1. LoadingView组件功 ...

  9. iOS开发系列--Swift进阶

    概述 上一篇文章<iOS开发系列--Swift语言>中对Swift的语法特点以及它和C.ObjC等其他语言的用法区别进行了介绍.当然,这只是Swift的入门基础,但是仅仅了解这些对于使用S ...

随机推荐

  1. css雪碧图生成工具4.1更新

    V4.0介绍地址:http://www.cnblogs.com/wang4517/p/4493917.html 此次更新主要针对已有BUG的修复,用户可在客户端上直接看到更新信息,自己去下载 已修复问 ...

  2. 查看文本[Linux]

    查看文本 不分屏查看 cat (默认标准输入到标准输出) -n(行号) 连接...并显示 -E(每行行尾打印$) 翻屏:shift+pageUp/pageDown tac reverse cat 分屏 ...

  3. SQL 谜题(硬币的组合)

    问题:早在ITPUB中看过有个SQL高手,喜欢出谜题,以下是一个谜题.我试用SQL SERVER解决此问题. 用1分,5分,10分,25分,50分硬币凑成一元,总共有几种组合办法? SELECT'1* ...

  4. 学习微信小程序之css9内边距

    padding内边距 <!DOCTYPE html> <html lang="en"> <head> <meta charset=&quo ...

  5. MIT 6.828 JOS学习笔记12 Exercise 1.9

    Lab 1中Exercise 9的解答报告 Exercise 1.9: 判断一下操作系统内核是从哪条指令开始初始化它的堆栈空间的,以及这个堆栈坐落在内存的哪个地方?内核是如何给它的堆栈保留一块内存空间 ...

  6. 【iOS atomic、nonatomic、assign、copy、retain、weak、strong】的定义和区别详解

    一.atomic与nonatomic 1.相同点 都是为对象添加get和set方法 2.不同点 atomic为get方法加了一把安全锁(及原子锁),使得方法get线程安全,执行效率慢 nonatomi ...

  7. MYSQL性能优化的最佳20+条经验

    MYSQL性能优化的最佳20+条经验 2009年11月27日 陈皓 评论 148 条评论  131,702 人阅读 今天,数据库的操作越来越成为整个应用的性能瓶颈了,这点对于Web应用尤其明显.关于数 ...

  8. 【vuejs小项目——vuejs2.0版本】组件化的开发方式

    对于多张页面需要里存在相同模块,可以进行组建化的开发模式. 例如:此处需要一个评分标准组件,创建一个components/star/star.vue. 在需要引入该组建的页面上 import进去< ...

  9. jquery轮播图详解,40行代码即可简单解决。

    我在两个月以前没有接触过html,css,jquery,javascript.今天我却在这里分享一篇技术贴,可能在技术大牛面前我的文章漏洞百出,也请斧正. 可以看出来,无论是div+css布局还是jq ...

  10. 尽量用goto代替尾递归

    void PrintList(List L) { if(L!=Null) { PrintElement(L->Element); PrintLisr(L->Next); } } 所谓尾递归 ...