【代码笔记】iOS-自定义loading
2024-10-19 03:36:46
一,效果图。
二,工程图。
三, 代码。
ViewController.h
#import <UIKit/UIKit.h>
//loading
#import "GPLoadingButton.h" @interface ViewController : UIViewController
{
//loading
GPLoadingButton *loadingButton;
UIView *backViewLoad;
} @end
ViewController.m
#import "ViewController.h" @interface ViewController () @end @implementation ViewController - (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib. //loading
[self addLoadingView];
}
//点击任何处,loading出现
-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
backViewLoad.hidden=NO;
loadingButton.hidden=NO;
[loadingButton startActivity];
//5s后loading消失
[self performSelector:@selector(loadingStop) withObject:nil afterDelay:2];
}
-(void)loadingStop
{
backViewLoad.hidden=YES;
loadingButton.hidden=YES;
[loadingButton stopActivity];
}
#pragma -mark --loading------
-(void)addLoadingView
{
backViewLoad=[[UIView alloc]initWithFrame:CGRectMake(0, 0,self.view.frame.size.width, self.view.frame.size.height)];
backViewLoad.backgroundColor=[UIColor blackColor];
backViewLoad.alpha=0.7;
backViewLoad.hidden=YES;
[self.view addSubview:backViewLoad]; loadingButton = [[GPLoadingButton alloc] initWithFrame:CGRectMake(self.view.frame.size.width/2-20, (self.view.frame.size.height-38)/2-20, 40, 40)];
loadingButton.rotatorColor = [UIColor colorWithRed:59/255.0 green:89/255.0 blue:152/255.0 alpha:1.0];
loadingButton.hidden=YES;
[self.view addSubview:loadingButton]; } - (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
} @end
最新文章
- 玩转spring boot——结合JPA入门
- C# ACCESS数据库操作类
- 三、基础功能模块,用户类别管理——锁、EF并发处理、领域服务、应用服务的划分
- 简单方便统一封装的傻瓜式GET/POST库AliasNet正式公布~开源喽~
- Windows 注册表操作
- 从 PHP 到 Java
- 【做题】ZJOI2017仙人掌——组合计数
- C语言---指针变量详解2
- Core DES加、解密
- Android绘制优化(一)绘制性能分析
- Spring框架的第四天(整合ssh框架)
- centos7: nginx安装配置
- 漏洞复现——tomcat远程代码执行漏洞
- 1118 Birds in Forest (25 分)
- ES6-Iterator &; for...of循环
- 使用UltraISO制作U盘启动
- docker微服务部署之:三,搭建Zuul微服务项目
- 项目经验:GIS<;MapWinGIS>;建模第五天
- 【bzoj3754】Tree之最小方差树 最小生成树
- 【spring源码学习】spring的IOC容器在初始化bean过程
热门文章
- MySQL 逻辑物理备份测试
- 在Storm的Toplogy中设置多数据源Spout
- Redis学习系列六ZSet(有序列表)及Redis数据结构的过期
- SSH远程连接Ubuntu Server
- ERROR tool.ImportTool: Encountered IOException running import job: java.io.IOException: Cannot run program ";hive";: error=2, No such file or directory
- java多线程并发控制countDownLatch和cyclicBarrier的使用
- 关于Android系统的启动流程
- logstash-2-插件配置
- tomcat关闭后线程依然运行解决办法
- offsetHeight,scrollHeight,clientHeight,scrollTop以及pageX,clientX,offsetX,screenX,offsetLeft,style.left等的区别以及使用详解