IOS-加载动态图(gif)
//
// BowenView.h
// IOS_0302_下拉刷新
//
// Created by ma c on 16/3/2.
// Copyright © 2016年 博文科技. All rights reserved.
// #import <UIKit/UIKit.h> @interface BowenView : UIView //要把loading界面加载到那个界面
+ (void)showBowenViewFromSuperView:(UIView *)superView;
//要把loading界面从哪个界面移除
+ (void)removeBowenViewFromSuperView:(UIView *)superView;
//要把loading界面加载到那个界面上(具体位置)
+ (void)showBowenViewFromSuperView:(UIView *)superView offSetY:(CGFloat)offSetY; @end //
// BowenView.m
// IOS_0302_下拉刷新
//
// Created by ma c on 16/3/2.
// Copyright © 2016年 博文科技. All rights reserved.
// #import "BowenView.h" @interface BowenView () //动态图
@property (nonatomic, strong) UIImageView *loadingImgView;
//提示文字
@property (nonatomic, strong) UILabel *lbl; @end @implementation BowenView - (instancetype)init
{
self = [super init];
if (self) {
[self addSubview:self.loadingImgView];
[self addSubview:self.lbl];
}
return self;
} - (UIImageView *)loadingImgView
{
if(!_loadingImgView){
_loadingImgView = [[UIImageView alloc] init];
_loadingImgView.frame = CGRectMake(, , , );
_loadingImgView.backgroundColor = [UIColor clearColor];
//动态图属性
_loadingImgView.animationImages = [self getImageArray];
_loadingImgView.animationDuration = 2.0;
_loadingImgView.animationRepeatCount = ;
}
return _loadingImgView;
} - (UILabel *)lbl
{
if(!_lbl){
_lbl = [[UILabel alloc] init];
_lbl.frame = CGRectMake(, , , );
_lbl.text = @"正在加载...";
_lbl.font = [UIFont systemFontOfSize:];
_lbl.textColor = [UIColor darkGrayColor];
_lbl.textAlignment = NSTextAlignmentCenter;
}
return _lbl;
}
//获取图片数组
- (NSArray *)getImageArray
{
NSMutableArray *imgArray = [NSMutableArray array];
NSMutableArray *imgNameArr = [NSMutableArray array]; for (int i=; i<; i++) { NSString *imgName = [NSString stringWithFormat:@"loading_animate_%02d",i];
[imgArray addObject:imgName];
} for (int i = ; i < ; i ++) {
UIImage *image = [UIImage imageNamed:[imgArray objectAtIndex:i]];
[imgNameArr addObject:image];
}
return imgNameArr; } //要把loading界面加载到那个界面
+ (void)showBowenViewFromSuperView:(UIView *)superView
{
[self showBowenViewFromSuperView:superView offSetY:];
}
//要把loading界面从哪个界面移除
+ (void)removeBowenViewFromSuperView:(UIView *)superView
{
//在父视图的【所有子视图数组中】查找
for (UIView *itemView in superView.subviews) {
if ([itemView isKindOfClass:[BowenView class]]) {
[itemView removeFromSuperview];
}
}
}
//要把loading界面加载到那个界面上(具体位置)
+ (void)showBowenViewFromSuperView:(UIView *)superView offSetY:(CGFloat)offSetY
{
BowenView *loadingView = [[BowenView alloc] init];
loadingView.frame = CGRectMake([UIScreen mainScreen].bounds.size.width/ - , + offSetY, , ); //判断superView上是否已经存在一个BowenView,如果已经存在,先删除,在加载新的View
[self removeBowenViewFromSuperView:superView];
[superView addSubview:loadingView]; //让动态图动起来
[loadingView.loadingImgView startAnimating]; } @end
IOS-加载动态图(gif)的更多相关文章
- iOS加载启动图的时候隐藏statusbar + 指定启动图显示多少秒
只需需要在info.plist中加入Status bar is initially hidden 设置为YES 补充一下,现在手机越来越快,在6+下面启动图一闪而过,而美工童鞋辛辛苦苦做的图就看不到鸟 ...
- iOS 加载动态库报错问题
dyld: Library not loaded: @rpath Referenced from: Reason: no suitable image found. Did find: 要么使用静态 ...
- Unity使用脚本进行批量动态加载贴图
先描述一下我正在做的这个项目,是跑酷类音游. 那么跑酷类音游在绘制跑道上的时候,就要考虑不同的砖块显示问题.假设我有了一个节奏列表,那么我们怎么将不同的贴图贴到不同的砖块上去呢? 我花了好几个小时才搞 ...
- 简易仿ios菊花加载loading图
原文链接:https://mp.weixin.qq.com/s/wBbQgOfr59wntNK9ZJ5iRw 项目中经常会用到加载数据的loading显示图,除了设计根据app自身设计的动画loadi ...
- 【转载】cocos2dx 中 Android NDK 加载动态库的问题
原文地址:http://blog.csdn.net/sozell/article/details/10551309 cocos2dx 中 Android NDK 加载动态库的问题 闲聊 最近在接入各 ...
- Java类的加载の动态
类的加载方式 静态加载类,是编译时刻加载 动态加载类,是运行时刻加载 new创建对象:是静态加载类,在编译时刻就需要加载所有的可能使用到的类.有一个类有问题(如不存在),都不能通过编译,会报错. Cl ...
- Android 高清加载巨图方案 拒绝压缩图片
Android 高清加载巨图方案 拒绝压缩图片 转载请标明出处: http://blog.csdn.net/lmj623565791/article/details/49300989: 本文出自:[张 ...
- Linux下c函数dlopen实现加载动态库so文件代码举例
dlopen()是一个强大的库函数.该函数将打开一个新库,并把它装入内存.该函数主要用来加载库中的符号,这些符号在编译的时候是不知道的.这种机制使得在系统中添加或者删除一个模块时,都不需要重新编译了. ...
- NGINX 加载动态模块(NGINX 1.9.11开始增加加载动态模块支持)
NGINX 1.9.11开始增加加载动态模块支持,从此不再需要替换nginx文件即可增加第三方扩展.目前官方只有几个模块支持动态加载,第三方模块需要升级支持才可编译成模块. tinywan@tinyw ...
- LoadLibrary加载动态库失败
[1]LoadLibrary加载动态库失败的可能原因以及解决方案: (1)dll动态库文件路径不对.此场景细分为以下几种情况: 1.1 文件路径的确错误.比如:本来欲加载的是A文件夹下的动态库a.dl ...
随机推荐
- discuz debug下载地址
Discuz!X会自带Debug模式,主要是用于排查性能问题.垃圾站建议当如果您的站点调试完之后,一定要把debug模式关闭,以免其他用户会获取到一些敏感信息.在调试过程中,config文件配置的 ...
- Web前端页面的浏览器兼容性测试心得(一)搭建测试用本地静态服务器
自从实习以来,我体验了由一个人编程再到多人协作编程的转换.同时也接触了很多新鲜事物,学到了很多东西.工作时,常常需要多个人协同测试一张H5页面(PC.手机.平板等跨设备测试),也会经常把页面给PM或老 ...
- CSS Dimension(尺寸)
CSS Dimension(尺寸) 一.简介 CSS 尺寸 (Dimension) 属性允许你控制元素的高度和宽度.同样,它允许你增加行间距. 二.Dimension(尺寸)属性值 三.示例 (1)示 ...
- [pixhawk笔记]11-Windows下PX4代码查看
由于项目需要做基于Simulink的PX4二次开发,在Windows下面做,所以需要在Windows下查看PX4的代码,故写该文档,记录环境安装和配置过程.按照该网页安装工具链:Windows Ins ...
- 照着官网来安装openstack pike之安装dashboard
上文提到了利用命令行下使用openstack的命令来创建虚拟机,这里选择安装dashboard来安装基于web界面的openstack平台 利用dashboard界面来创建虚拟机 dashboard这 ...
- 如何使用openwrt下的分区表生成器ptgen
1.基本用法如下: ptgen [-v] -h <heads> -s <sectors> -o <outputfile> [-a 0..4] [-l <ali ...
- Redis维护
关闭redis [root@--x-x log]# cd /usr/local/redis/bin/ [root@--x-x bin]# ./redis-cli -h shutdown 启动redis ...
- log4j:ERROR A "org.apache.log4j.DailyRollingFileAppender" object is not assignable to a "org.apache.log4j.Appender" variable.
多个classloader加载log4j时需要设置当前Thread的classloader为你自己的classloader Thread.currentThread().setContextClass ...
- 【分类】AlexNet论文总结
目录 0. 论文链接 1. 概述 2. 对数据集的处理 3. 网络模型 3.1 ReLU Nonlinearity 3.2 Training on multiple GPUs 3.3 Local Re ...
- CentOS7配置自定义JDK
由于选择的是centos7-dvd镜像自带了open jdk,需要卸载.首先查询自带的jdk: rpm -qa | grep java 会出现7个带有java名称的东西,删除其中的带有openjdk字 ...