#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. BZOJ3853 : GCD Array

    1 n d v相当于给$a[x]+=v[\gcd(x,n)=d]$ \[\begin{eqnarray*}&&v[\gcd(x,n)=d]\\&=&v[\gcd(\fr ...

  2. 【BZOJ】1015: [JSOI2008]星球大战starwar(并查集)

    http://www.lydsy.com/JudgeOnline/problem.php?id=1015 看了题解的囧T_T,一开始以为是求割点,但是想到割点不能统计.... 这题用并查集,思想很巧妙 ...

  3. HTML5怎样在网页中使用摄像头功能

    怎样在网页中使用摄像头,html5越来越多的使用到实际工作中,那么他怎样调用摄像头呢进行视频聊天,视频监控等活动呢,今天为大家抛砖引玉,教大家怎样实现怎样利用html5实现摄像头视频监控功能.废话不多 ...

  4. html5文章 -- 应用HTML5 开发手机APP

    因为HTML5暂时无法短期内在PC普及,主要方向在使用高端浏览器的高端移动设备,所以可以用作开发Android系统的App.但只有Android2.2以上.iOS3.2以上均支持HTML5,两大平台有 ...

  5. dpi,ppi,dip,dp,px和sp

    一 基本概念 1. dpi (dots per inch)每英寸多少点:ppi( Pixel per inch),每英寸像素数.针对显示器的设计时,dpi=ppi. 2. dip (device in ...

  6. gnuplotx轴的logscale显示

    假设数据是这样子的: gnuplot脚本如下: set terminal postscript eps color enhanced set log x set log y set format x ...

  7. 结合计划任务每天从Symantec官网下载离线病毒库

    #三种方法,由初级到高级 $numbers = 1..40 | Foreach {"{0:D3}" -f $_} #将数字类型格式化并转换为字符串类型使用-f字符串操作符 ForE ...

  8. sqlserver ldf过大处理方法

    第一步 DUMP TRANSACTION   databasename  WITH   NO_LOG  -- 第二步:截断事务日志  BACKUP LOG   databasename   WITH  ...

  9. c++ windows 获取mac地址

    c++ windows 获取mac地址 GetAdaptersInfo 用windows api获取mac地址和硬盘id编号 aa

  10. Mininet实验 使用l2_multi模块寻找最短路径实验

    参考:使用l2_multi模块寻找最短路径实验 1. 实验目的 1.认识VND并且掌握其基本使用方法. 2.学会使用pox控制器的l2_multi模块寻找主机间的最短传输路径. 2. 实验原理 VND ...