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 ...
随机推荐
- BZOJ3828 : [Poi2014]Criminals
对于每个位置求出L[i]表示左边最大的j,满足从j开始到i-1中存在第一个子序列 R[i]表示右边最小的j,满足从j开始到i-1中存在第二个子序列 然后枚举颜色是相遇点的位置,如果L[i]左边.R[i ...
- #region 自适应屏幕分辨率
#region 自适应屏幕分辨率 [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)] public ...
- [leetCode][013] Two Sum 2
题目: Given an array of integers that is already sorted in ascending order, find two numbers such that ...
- GIT用法总结
1 git中的几种文件状态 a 未被git跟踪的文件,即是没有使用git add添加到git索引的的文件:untracked; b 没有修改但是已经被git跟踪的文件,即是使用git add添加到gi ...
- 关于APP自动化工程的一点小想法
首先谈一下APP自动化测试面临的一些局限性? 答:测试业务的不明确性,APP逻辑复杂,界面的跳转变化随时间变化. 测试本身的不确定性,如不定时弹窗问题. 测试环境不稳定性,主要是网络的稳定性. 测试接 ...
- java图片处理——多张图片合成一张Gif图片并播放或Gif拆分成多张图片
1.多张jpg图合成gif动画 /** * 把多张jpg图片合成一张 * @param pic String[] 多个jpg文件名 包含路径 * @param newPic String 生成的gif ...
- Ubuntu 下误修改用户组导致sudo命令无效
1.手贱地修改了当前用户的权限组,导致sudo命令无法使用,且root用户的密码尚未修改,登陆不了root用户. 2.切换到recoverymode ,使用root用户登陆 3.执行mount -o ...
- Error 2147943712 during task creation
In a Windows 2008 server, when you confirm the creation of a new task, you may obtain the following ...
- 通过IP的方式建立PSSession
Import-Module PoshWSUS Connect-PoshWSUSServer -WsusServer cnhzsrv09 Get-PoshWSUSClient | Select-Obje ...
- li标签行内元素高度及居中
<head> <title><title> <style type="text/css"> * { padding: 0px; ma ...