swift gcd 定时器。获取验证码
来源:互联网 发布:linux 远程执行命令 编辑:程序博客网 时间:2024/05/21 10:21
//获取验证码
func getCodeButtonTouch(sender:UIButton) {
//在获取期间不允许点击
sender.backgroundColor =UIColor.gray
sender.isUserInteractionEnabled =false
var count =60;
let timer =DispatchSource.makeTimerSource()
timer.setEventHandler {
count -= 1
DispatchQueue.main.async {
self.codeBtn?.setTitle("获取(\(count)s)", for: UIControlState.normal)
}
}
timer.setCancelHandler {
DispatchQueue.main.async {
self.codeBtn?.isUserInteractionEnabled = true
self.codeBtn?.backgroundColor =MAIN_COLOR
self.codeBtn?.setTitle("获取(60s)", for: UIControlState.normal)
}
}
//间隔 1 总时间 60
timer.scheduleRepeating(deadline: .now(), interval: .seconds(1), leeway: .milliseconds(60))
timer.resume()
//59秒时执行
DispatchQueue.main.asyncAfter(deadline: .now() + .seconds(59), execute:{
timer.cancel()
})
//获取验证码
getCodeRequest()
//收起键盘
self.view.endEditing(true)
}
- swift gcd 定时器。获取验证码
- 定时器,获取验证码
- 运用GCD谱写验证码定时器
- 获取验证码的定时器
- 用GCD实现获取验证码效果
- Android 定时器 验证码获取显示
- 通过GCD实现获取验证码的倒计时
- GCD线程间通信及合成图片、获取验证码
- iOS GCD实现获取验证码的倒计时
- swift GCD-定时器(DispatchSourceTimer)注册登陆组件封装
- Swift 4.0中 GCD定时器写法,及延时操作
- Android thread+handler实现获取验证码定时器
- GCD定时器
- GCD定时器
- GCD 定时器
- GCD 定时器
- GCD定时器
- GCD定时器
- try catch 对性能影响
- codeforces 818E Card Game Again (尺取法)
- numpy.random 的函数基本用法
- [Python]网络爬虫总结
- Linux下使用RecordMyDesktop进行屏幕录像 输出图像格式转换
- swift gcd 定时器。获取验证码
- css3新特性
- 文字处理控件TX Text Control .NET for WPF 历史大版本X14发布 | 附下载
- DBhelper的使用
- CentOS中输入yum报错:sudo: unable to execute /bin/yum: No such file or directory
- html学习笔记(一)
- Android实现国际化
- 面向对象程序设计的术语
- 欢迎使用CSDN-markdown编辑器