button获取验证码60秒倒计时 直接用
__block int time = ;
__block UIButton *verifybutton = _GetverificationBtn;
verifybutton.enabled = NO;
dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, );
dispatch_source_t _timer = dispatch_source_create(DISPATCH_SOURCE_TYPE_TIMER, , ,queue);
dispatch_source_set_timer(_timer,dispatch_walltime(NULL, ),1.0*NSEC_PER_SEC, ); //每秒执行
dispatch_source_set_event_handler(_timer, ^{
if(time<=){ //倒计时结束,关闭
dispatch_source_cancel(_timer);
dispatch_async(dispatch_get_main_queue(), ^{
//设置界面的按钮显示 根据自己需求设置
verifybutton.backgroundColor = [UIColor colorWithHexString:@"FC740A"];
[verifybutton setTitle:@"获取验证码" forState:UIControlStateNormal];
verifybutton.enabled = YES;
});
}else{
dispatch_async(dispatch_get_main_queue(), ^{
//设置界面的按钮显示 根据自己需求设置
verifybutton.backgroundColor = [UIColor grayColor];
NSString *strTime = [NSString stringWithFormat:@"获取验证码(%d)",time];
[verifybutton setTitle:strTime forState:UIControlStateNormal];
verifybutton.titleLabel.textColor = [UIColor whiteColor];
});
time--;
}
});
dispatch_resume(_timer);
button获取验证码60秒倒计时 直接用的更多相关文章
- iOS-登录发送验证码时60秒倒计时,直接用
__block NSInteger timeout= ; //倒计时时间 KWeakSelf dispatch_queue_t queue = dispatch_get_global_queue(DI ...
- uni验证码60秒倒计时
其实要实现这个功能原理非常简单,就是setInterval+setTimeout+clearInterval结合使用,首先在data里定义一个变量second,初始值为60,然后在setInterva ...
- js实现60秒倒计时效果(使用了jQuery)
今天碰到要实现一个类似那种短信验证码60秒倒计时的需求,好久不写js,有点手生.把代码记录下,方便后续查阅. 这里我用了jQuey,毕竟写起来简洁点.下面直接看效果和代码. 一.效果 ...
- 微信小程序60秒倒计时
微信小程序发送短信验证码后60秒倒计时功能,效果图: 完整代码 index.wxml <!--index.wxml--> <view class="container&qu ...
- 获取验证码,60秒倒计时js
<input type="button" id="btn" value="免费获取验证码" /><script type= ...
- jQuery实现发送短信验证码后60秒倒计时
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <script sr ...
- iOS “获取验证码”按钮的倒计时功能
iOS 的倒计时有多种实现细节,Cocoa Touch 为我们提供了 NSTimer 类和 GCD 的dispatch_source_set_timer方法去更加方便的使用计时器.我们也可以很容易的的 ...
- Angular.js 使用获取验证码按钮实现-倒计时
获取验证码界面效果如图: 需要实现以下逻辑 按钮不可选 --输入电话号码,按钮可选 --点击获取,进入倒计时,按钮不可选 --倒计时结束,回到初识状态 核心代码: var cd = 60; var t ...
- 点击按钮出现60秒倒计时js代码
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...
随机推荐
- EMbedding
FNN模型:非端到端 输入 --> 特征onehot --->FM 模型--->输出每个特征权重及因子值 ----> 输入神经网络 ----> 输出每个预测值 此为一 ...
- python错题整理
1.列表list去重 l1 = [1,1,2,3,5,5,4,4,4,5,6] set1 = set(l1) # print(set1) # set是集合 l2 = list(set1) # 将集合转 ...
- elasticsearch 测试
https://www.yiibai.com/elasticsearch/elasticsearch-getting-start.html # curl -XPUT "http://loca ...
- find命令归总
-amin n (主要指是否被读取过)对文件的最近一次访问是在 n 分钟之前. 例如:find /opt/* -amin 1 -type f (找出1分钟之前的/opt下的所有文件) -atime ...
- HDU 6351 Naive Operations(线段树)
题目: http://acm.hdu.edu.cn/showproblem.php?pid=6315 Naive Operations Time Limit: 6000/3000 MS (Java/O ...
- php 5.3.10 cli 模式加载php_openssl.dll
问题描述: 开启php_openssl.dll,仍提示php_openssl.dll required/Not found 原因:可能是php的版本跟php_openssl.dll的版本不一样 具体排 ...
- Activty左出右进动画
[Activty左出右进动画] public void overridePendingTransition (int enterAnim, int exitAnim) 其中: enterAnim 定义 ...
- XSSExcelUtil
package com.numa.util; import org.apache.poi.hssf.usermodel.*;import org.apache.poi.hssf.util.HSSFCo ...
- 无线渗透开启WPS功能的路由器
首先关闭网络服务 service network-manager stop wps一般可在10-20小时可以爆破开,攻击难度较低,有一些厂家的无线路由甚至无法关闭WPS功能. 开始侦听开启wps功能的 ...
- 解题9(StringReversedOrder)
题目描述 将一个英文语句以单词为单位逆序排放.例如“I am a boy”,逆序排放后为“boy a am I”所有单词之间用一个空格隔开,语句中除了英文字母外,不再包含其他字符 接口说明 /** * ...