LoadingView 自定义加载图片
#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 自定义加载图片的更多相关文章
- ImageLoader加载图片
先导universal-image-loader-1.9.3包 在application配置 android:name=".MyApplication" intent权限 1 pa ...
- 利用Volley封装好的图片缓存处理加载图片
Volley 工具箱中提供了一种通过 DiskBasedCache 类实现的标准缓存.这个类能够缓存文件到磁盘的指定目录.但是为了使用 ImageLoader,我们应该提供一个自定义的内存 LRC b ...
- Glide 加载图片
//通过model获取到图片的url,将Url转换成bitmap对象: //设置不保存内存和硬盘缓存, 1 Glide.with(mContext).load(model.getVideoUrl()) ...
- Android之使用Android-AQuery异步加载图片(一)
第一节:转载地址(http://www.cnblogs.com/lee0oo0/archive/2012/10/25/2738299.html) // 必须实现AQuery这个类 AQuery aq ...
- Android中ListView异步加载图片错位、重复、闪烁问题分析及解决方案
我们在使用ListView异步加载图片的时候,在快速滑动或者网络不好的情况下,会出现图片错位.重复.闪烁等问题,其实这些问题总结起来就是一个问题,我们需要对这些问题进行ListView的优化. 比如L ...
- 使用UIL(Universal-Image-Loader)异步加载图片
概要: Android-Universal-Image-Loader是一个开源的UI组件程序,该项目的目的是实现可重复使用的异步图像加载.缓存和显示.所以,如果你的程序里需要这个功能的话,使用它,因为 ...
- 图片--Android加载图片导致内存溢出(Out of Memory异常)
Android在加载大背景图或者大量图片时,经常导致内存溢出(Out of Memory Error),本文根据我处理这些问题的经历及其它开发者的经验,整理解决方案如下(部分代码及文字出处无法考证) ...
- 多线程异步加载图片async_pictures
异步加载图片 目标:在表格中异步加载网络图片 目的: 模拟 SDWebImage 基本功能实现 理解 SDWebImage 的底层实现机制 SDWebImage 是非常著名的网络图片处理框架,目前国内 ...
- ListView与GridView异步加载图片
原理很简单,主要是用到了回调方法,下面是异步加载图片的类 <span style="font-size:16px;">package com.xxx.xxx; impo ...
随机推荐
- COJ0700 数学(一)
试题描述 现在有一大堆数,请你对这些数进行检验. 输入 第一行:CAS,代表数据组数(不大于500000),以下CAS行,每行一个数字,保证在64位长整形范围内,并且没有负数.你需要对于每个数字检验是 ...
- HttpClient_用Apache HttpClient实现URL重定向
很多网站都使用了URL重定向技术,把一个原始请求从一个位置路由到另一个位置.原因可能是多方面的,比如域名转发.URL缩写.隐私保护.在同一网站维持相似的域名等.本文讲述怎样使用Apache HTTPC ...
- JAVA发送邮件工具类
import java.util.Date;import java.util.Properties; import javax.mail.BodyPart;import javax.mail.Mess ...
- Hibernate使用MyExclipse10自动生成配置文件报错
使用MyExclipse10自动生成hibernate映射文件如下: 结果发现启动服务时报以下错误: 原因:因为hibernate换过项目地址,所以dtd文件的地址也换掉了.在hbm.xml文件里面把 ...
- 从prompt输入10个人的年龄放入数组,将十个人的年龄求总和。
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...
- [转]3天搞定的小型B/S内部管理类软件定制开发项目【软件开发实战10步骤详解】
本文转自:http://www.cnblogs.com/jirigala/archive/2010/10/07/1845275.html 2010-10-07 21:39 by 通用C#系统架构, 5 ...
- 9. Add the Block Storage service
Block Storage Server: 1. sudo apt-get install python-mysqldb 2. sudo apt-get install lvm2 3. 创建存 ...
- Mac 配置环境变量
系统:mac OS 10.10.3 or later 1.如果不能使用一些常用终端命令,如ls,open.可能是环境变量配置不当导致的.尤其是手动修改 输入以下命令: export PATH=/us ...
- [转]Jquery通用开源框架之【ejq.js】
ejq是一款非常小巧的JS工具库,未压缩才50K,在jquery的基础上对jquery缺失部分作了很好的弥补作用. 优点: 1.具有内置的模板解析引擎语法和angularjs相近减少学习成本 2.能够 ...
- 完美解决VS2003.Net fatal error LNK1201: 写入程序数据库“.pdb”时出错
我的开发环境是Win7旗舰64位+VS2003.Net,经常卡pdb错误,文末给出一个完美的解决方案和一个懒人补丁包.问题描述如下:在重新编译的时候,经常报错: fatal error LNK1201 ...