#import <UIKit/UIKit.h>

@interface LoadingView : UIView

@property (nonatomic,strong) NSMutableArray *giftImageArray;

+(id)showLoadingView;

+(void)hidenLoadingView:(LoadingView *)loadingView;

@end

#import "LoadingView.h"

- (instancetype)init

{

self = [super init];

if (self) {

self.frame = CGRectMake( 0, 0, ScreenWidth, ScreenHeight);

UIView *backView = [[UIView alloc]initWithFrame:CGRectMake( 0, 0, ScreenWidth, ScreenHeight)];

backView.backgroundColor = [UIColor blackColor];

backView.alpha = 0.7;

[self addSubview:backView];

}

return self;

}

+(id)showLoadingView{

LoadingView *loadingView = [[LoadingView alloc]init];

NSMutableArray *array = [NSMutableArray array];

for (int i = 0; i < 7; i++) {

UIImage *image = [UIImage imageNamed:[NSString stringWithFormat: @"loading_da%d",i+1]];

[array addObject:image];

}

UIImageView *loading = [[UIImageView alloc]initWithFrame:CGRectMake( ScreenWidth/2-Width(77), ScreenHeight/2 - Width(77), Width(154), Width(154))];

[loadingView addSubview:loading];

[UIView animateWithDuration:1 animations:^{

} completion:^(BOOL finished) {

loadingView.giftImageArray = array;

loading.animationDuration = 0.7;

loading.animationImages = loadingView.giftImageArray;

loading.animationRepeatCount = 0;

loading.image = [loadingView.giftImageArray firstObject];

[loading startAnimating];

}];

[loadingView show];

return loadingView;

}

+(void)hidenLoadingView:(LoadingView *)loadingView{

[loadingView performSelector:@selector(hide) withObject:nil afterDelay:0.4];

}

//添加 背景灰度

- (void)show{

//添加到window上 就不需要再次添加到self.view上了

UIWindow *win = [[UIApplication sharedApplication] keyWindow];

UIView *topView = [win.subviews objectAtIndex:0];

[topView addSubview:self];

[UIView animateWithDuration:0.1 animations:^{

[self layoutIfNeeded];

}];

}

- (void)hide{

[UIView animateWithDuration:0.1 animations:^{

self.alpha = 0;

[self layoutIfNeeded];

} completion:^(BOOL finished) {

[self removeFromSuperview];

}];

}

LoadingView 自定义加载图片的更多相关文章

  1. ImageLoader加载图片

    先导universal-image-loader-1.9.3包 在application配置 android:name=".MyApplication" intent权限 1 pa ...

  2. 利用Volley封装好的图片缓存处理加载图片

    Volley 工具箱中提供了一种通过 DiskBasedCache 类实现的标准缓存.这个类能够缓存文件到磁盘的指定目录.但是为了使用 ImageLoader,我们应该提供一个自定义的内存 LRC b ...

  3. Glide 加载图片

    //通过model获取到图片的url,将Url转换成bitmap对象: //设置不保存内存和硬盘缓存, 1 Glide.with(mContext).load(model.getVideoUrl()) ...

  4. Android之使用Android-AQuery异步加载图片(一)

    第一节:转载地址(http://www.cnblogs.com/lee0oo0/archive/2012/10/25/2738299.html) // 必须实现AQuery这个类 AQuery aq ...

  5. Android中ListView异步加载图片错位、重复、闪烁问题分析及解决方案

    我们在使用ListView异步加载图片的时候,在快速滑动或者网络不好的情况下,会出现图片错位.重复.闪烁等问题,其实这些问题总结起来就是一个问题,我们需要对这些问题进行ListView的优化. 比如L ...

  6. 使用UIL(Universal-Image-Loader)异步加载图片

    概要: Android-Universal-Image-Loader是一个开源的UI组件程序,该项目的目的是实现可重复使用的异步图像加载.缓存和显示.所以,如果你的程序里需要这个功能的话,使用它,因为 ...

  7. 图片--Android加载图片导致内存溢出(Out of Memory异常)

    Android在加载大背景图或者大量图片时,经常导致内存溢出(Out of Memory  Error),本文根据我处理这些问题的经历及其它开发者的经验,整理解决方案如下(部分代码及文字出处无法考证) ...

  8. 多线程异步加载图片async_pictures

    异步加载图片 目标:在表格中异步加载网络图片 目的: 模拟 SDWebImage 基本功能实现 理解 SDWebImage 的底层实现机制 SDWebImage 是非常著名的网络图片处理框架,目前国内 ...

  9. ListView与GridView异步加载图片

    原理很简单,主要是用到了回调方法,下面是异步加载图片的类 <span style="font-size:16px;">package com.xxx.xxx; impo ...

随机推荐

  1. ZOJ 3494 (AC自动机+高精度数位DP)

    题目链接:  http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3494 题目大意:给定一些被禁止的BCD码.问指定范围内不含有 ...

  2. 使用WebRequest 检测 手机号归属地。 C#通用 使用json 和可设定超时的WebClient

    首先建立jsonObject,当然你也可以使用xml解析,目前介绍一下我使用的方法. /******************************************************** ...

  3. linux fork 进程后 主进程的全局变量

    fork一个进程后,复制出来的task_struct结构与系统的堆栈空间是父进程独立的,但其他资源却是与父进程共享的,比如文件指针,socket描述符等 不同的进程使用不同的地址空间,子进程被创建后, ...

  4. MatLab GUI Load .mat File 导入mat文件

    在MatLab中,我们用GUI时,有时候需要导入mat格式的图片,但是在GUI中调用load和在命令行里调用load不一样,在命令行里调用load('im.mat'),加载进去是uint8的矩阵,但是 ...

  5. myeclipse10 .jsp将表单提交给.java(form网页与后台通信初识)

    做毕设需要用到form通信. 以下几张截图来自极课学院 servlet jsp文件 web配置 出现错误: 路径问题 仍然不对,需要再改 <form action="servlet/S ...

  6. CSS3 2D Transform

    在 一个二维或三维空间,元素可以被扭曲.移位或旋转.只不过2D变形工作在X轴和Y轴,也就是大家常说的水平轴和垂直轴:而3D变形工作在X轴和Y轴之外, 还有一个Z轴.这些3D变换不仅可以定义元素的长度和 ...

  7. yii2.0安装创建应用shiyong 归档文件安装

    环境是wamp在本机开发 http://www.yiiframework.com/download/ Install from an Archive File Download one of the ...

  8. 《Ant权威指南》笔记(一)

    Ant的由来(序) James Duncan Davidson当年用纯Java开发Tomcat的时候,不仅想让它跨平台运行,还想要在不同的操作系统上都能够进行开发和构建.这种较大的项目的编译构建过程是 ...

  9. 【翻译】Kinect v2程序设计(C++) Depth编

    Kinect SDK v2预览版,取得Depth数据的方法说明. 上一节,介绍了通过使用Kinect for Windows SDK v2预览版(以下简称为,Kinect SDK v2预览版)从Kin ...

  10. ExtJS笔记2 Class System

    For the first time in its history, Ext JS went through a huge refactoring from the ground up with th ...