#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. C#的泛型委托Predicate/Func/Action(转)

    Predicate 泛型委托:表示定义一组条件并确定指定对象是否符合这些条件的方法.此委托由 Array 和 List 类的几种方法使用,用于在集合中搜索元素. 类型参数介绍:    T: 要比较的对 ...

  2. COJ0700 数学(一)

    试题描述 现在有一大堆数,请你对这些数进行检验. 输入 第一行:CAS,代表数据组数(不大于500000),以下CAS行,每行一个数字,保证在64位长整形范围内,并且没有负数.你需要对于每个数字检验是 ...

  3. Hashtable和Dictionary<T,K>的使用

    由于Hashtable内部自带有排序(根据Key的HashCode来进行的),因此有时在使用Hashtable时就会造成数据顺序不可控的情况,有两种办法可以解决, 测试代码: Dictionary&l ...

  4. winform学习-----理解小概念-20160517

    1.MouseDown事件 当鼠标指针位于控件上并按下鼠标键时发生. 2.MouseUp事件 当鼠标指针在控件上并释放鼠标按键时发生. 与 mouseout 事件不同,只有在鼠标指针离开被选元素时,才 ...

  5. https资料

    1.HTTPS的七个误解   http://blog.httpwatch.com/2011/01/28/top-7-myths-about-https/ 中文 http://www.cnblogs.c ...

  6. WPF的Page介绍及Page Window Frame 之间的链接使用示例,嵌套问题

    本文源参考 http://www.cnblogs.com/ListenFly/archive/2013/02/24/2923474.html 谢谢源作者 WPF中的Page相比Window来说更加的精 ...

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

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

  8. Java下利用Jackson进行JSON解析和序列化

    Java下利用Jackson进行JSON解析和序列化   Java下常见的Json类库有Gson.JSON-lib和Jackson等,Jackson相对来说比较高效,在项目中主要使用Jackson进行 ...

  9. centeros iptable模板文件

    iptables规则是空的.而且他们的selinux是关闭了的,这等同于把系统裸奔(总比windows裸奔好).   使用方法: 1.用root用户登录后 vi /etc/sysconfig/ipta ...

  10. 【SIGGRAPH 2015】【巫师3 狂猎 The Witcher 3: Wild Hunt 】顶级的开放世界游戏的实现技术。

    [SIGGRAPH 2015][巫师3 狂猎 The Witcher 3: Wild Hunt ]顶级的开放世界游戏的实现技术 作者:西川善司 日文链接  http://www.4gamer.net/ ...