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 ...
随机推荐
- redis 慢查询日志
说明:针对慢查询日志,可以设置两个参数,一个是执行时长,单位为微秒,另一个是慢查询日志的长度.如果超过该长度,当一个新的命令被写入日志时,最老的一条会从命令日志队列中被移除. 编辑配置文件redis. ...
- [pixhawk笔记]5-uORB消息传递
本文主要内容翻译自官方文档:https://dev.px4.io/en/middleware/uorb.html 在前一篇笔记中使用uORB完成消息传递,实现了一个简单示例程序,本文将对uORB进行系 ...
- flex 的总结
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
- openwrt生成的镜像放在哪里
答:1.打包好之后是放在build_dir/target-$(cross-compile-toolchan-name)/linux-$(chip-series-name)_$(chip-arch)/t ...
- BZOJ 3192: [JLOI2013]删除物品 奇淫技巧&树状数组
点我看题 这题十分奇淫技巧...QAQ因为知道是树状数组的题QAQ刚开始以为维护两个数组的树状数组然后模拟从大到小,然后发现不会打QAQ 于是悄悄咪咪翻开题解了. 实际上两个数组可以看做一个数组 如 ...
- IPFS星际节点网站 IPNS域名解析教程
IPNS星际文件系统IPFS提供的域名命名空间,相当于经典HTTP协议中的DNS.只不过是,IPNS是将内容寻址的哈希值(HASH值)转换为域名,而DNS是将IP地址转换为域名. 前段时间,IPFS协 ...
- Python学习札记(二十一) 函数式编程2 map/reduce
参考:map/reduce Note 1.map():map()函数接收两个参数,一个是函数,一个是Iterable.map将传入的函数依次作用到序列的每个元素,并把结果作为新的Iterator返回. ...
- MAC OS 命令行使用详解【转】
你可以整天驾驶汽车而不用知道如何修理它们,但是如果你希望当一个维护员,你就需要知道事情是如何运作的.同样的事情也发生在了 Mac OS X 上:你可以一直使用 Mac 而不用知道如何修理它,但是如果你 ...
- 一款简单易用的.Net 断言测试框架 : Shouldly
GitHub地址:https://github.com/shouldly/shouldly Shouldly的官方文档:http://docs.shouldly-lib.net/ Nuget安装: 在 ...
- u-boot-2015.07 autoconf.mk生成过程分析
1.u-boot2015.7版本编译没有在顶层目录中生成.config文件,而生成了include/autoconf.mk和include/autoconf.mk.dep两个文件,并在每个模块编译的时 ...