#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. javascript为元素绑定事件响应函数

    javascript中为元素设置响应时间有两种方法. (1):object.onclick=functionName; 这种方法不可以传递参数. (2):object.onclick=function ...

  2. TYVJ P1022 进制转换 Label:坑

    背景 太原成成中学第3次模拟赛 第2道 描述 对于十进制整数N,试求其-2进制表示.例如,因为 1*1 + 1*-2 + 1*4 + 0*-8 +1*16 + 1*-32 = -13 ,所以(-13) ...

  3. 常用移动web开发框架研究分析

    纯粹的总结一下移动web开发框架,移动web开发框架有jQuery Mobile .Sencha Touch等等,他们都来源于web开发,是成熟的框架,jQuery Mobile出自于jQuery家族 ...

  4. 【BZOJ】1441: Min(裴蜀定理)

    http://www.lydsy.com/JudgeOnline/problem.php?id=1441 这东西竟然还有个名词叫裴蜀定理................ 裸题不说....<初等数 ...

  5. BZOJ3772: 精神污染

    Description 兵库县位于日本列岛的中央位置,北临日本海,南面濑户内海直通太平洋,中央部位是森林和山地,与拥有关西机场的大阪府比邻而居,是关西地区面积最大的县,是集经济和文化于一体的一大地区, ...

  6. COJ986 WZJ的数据结构(负十四)

    WZJ的数据结构(负十四) 难度级别:D: 运行时间限制:6000ms: 运行空间限制:262144KB: 代码长度限制:2000000B 试题描述 请你设计一个数据结构,完成以下功能: 给定一个大小 ...

  7. linux下查看一个进程的启动时间和运行时间

    使用 ps命令 :#ps -A -opid,stime,etime,args ps -A -opid,stime,etime,args 结果: root:src# ps -A -opid,stime, ...

  8. 如何快速查找IP归属地

    这两天遇到这么一个问题,就是查找一个IP的归属地.当然我会有一个IP段的分配列表,格式如下: 16777472    16778239    XX省 XX市 第一列是IP段的起始IP,第二列是IP段的 ...

  9. java编译自动化

    java编译自动化 http://h2ofly.blog.51cto.com/6834926/1545452?utm_source=tuicool&utm_medium=referral

  10. fibonacci数列 java

    public class Fibonacci { public static void main(String agrs[]) { ;j<=;j++) System.out.println(fo ...