Swift3 倒计时按钮扩展
extension UIButton{
func overrideSelf(){
self.setTitle("验证码", for: .normal)
self.titleLabel?.font = UIFont.systemFont(ofSize: 13)
self.addTarget(self, action: #selector(tf), for: .touchUpInside)
self.setTitleColor(UIColor.orange, for: .normal)
self.layer.cornerRadius = 15
self.layer.borderWidth = 1
self.layer.borderColor = color_navView.cgColor
self.layer.masksToBounds = true
}
func tf(){
Timer.scheduledTimer(timeInterval: 1, target: self, selector: #selector(timerAction(timer:)), userInfo: nil, repeats: true).fire()
}
func timerAction(timer:Timer){
tag -= 1
if tag < 0 {
self.isUserInteractionEnabled = true
self.layer.borderColor = color_navView.cgColor
self.setTitle("重新获取", for: .normal)
self.setTitleColor(UIColor.orange, for: .normal)
timer.invalidate()
tag = 30
}else{
self.isUserInteractionEnabled = false
self.layer.borderColor = UIColor.gray.cgColor
self.setTitle("剩余\(tag)s", for: .normal)
self.setTitleColor(UIColor.gray, for: .normal)
}
}
func getVerificationCode(){
//let st = STools()
// st.getVercodeAction(cityCode: appDelegate.cityCode, mobile: appDelegate.vphone, verificationCodeType: appDelegate.verificationStr)
// st.verificationInfo { (info:String) in
// if info != "验证码已发送"{//失败了
// self.tag = 0
// }
// appDelegate.window.rootViewController?.showHint(info)
// }
}
}
//MARK:调用
codeBtn.overrideSelf()
codeBtn.tag = 30
codeBtn.addTarget(self, action: #selector(getVercodeAction(_:)), for: .touchUpInside)
func getVercodeAction(_ sender: Any) {
codeBtn.getVerificationCode()
}
Swift3 倒计时按钮扩展的更多相关文章
- iOS 短信验证码倒计时按钮的实现
验证码倒计时按钮的应用是非常普遍的,本文介绍了IOS实现验证码倒计时功能,点击获取验证码,进入时间倒计时,感兴趣的小伙伴们可以参考一下: 实现思路: 创建按钮,添加点击方法: 用NSTimer定时器, ...
- angularjs使用directive实现倒计时按钮
前不久在做一个彩票的项目时,有一个手动开奖的需求.所以有了这个倒计时按钮.下面分享下具体的代码: 效果: 代码: App.directive('timerBtn', function() { // 倒 ...
- delphi倒计时按钮写法
procedure TForm1.FormActivate(Sender: TObject); var i: Integer; begin btn8.Enabled:=False; do begin ...
- jquery倒计时按钮常用于验证码倒计时
<!doctype html><html><head> <meta charset="utf-8"> <title>jq ...
- React实战之60s倒计时按钮(发送短信验证按钮)
React实战之60s倒计时按钮——短信验证按钮 导入:(antd组件——Form表单) import { Button, Form, Input } from 'antd'; const FormI ...
- 前端学习——ionic/AngularJs——获取验证码倒计时按钮
按钮功能为:点击"获取验证码"--按钮不可用-设置倒计时-60秒后重新获取. 代码借鉴于:http://plnkr.co/edit/Swj82MpJSix3a47jZRHP?p= ...
- Android 倒计时按钮,倒计时发送短信验证码…
Android基础之——CountDownTimer类,轻松实现倒计时功能https://www.cnblogs.com/yfceshi/p/6853746.html android中获取验证码后出现 ...
- Android中注册获取验证码倒计时按钮
public class CountDownTimerUtils extends CountDownTimer { private TextView mTextView; /** * @param t ...
- UWP 发送短信公用倒计时按钮
1.要求: 发送验证码按钮,点击后,会倒计时60s,之后才能再次点击.不同界面的多个验证码按钮共享这个倒计时时间. 2.操作步骤 1) 从登录界面-->忘记密码输入手机号- ...
随机推荐
- JoyOI1940 创世纪
一道基环树+树形\(DP\) 原题链接 显然输入的是内向基环树森林,且我们可以单独考虑每一棵基环树. 既然是基环树,自然先\(dfs\)找环,然后随便找环上的一点\(r\),将其与\(A[r]\)的边 ...
- 04. pt-deadlock-logger
死锁:是指两个或则多个事务在同一个资源上相互占用,并请求锁定对方占用的资源,而导致恶性循环的现象:当产生死锁的时候,MySQL会回滚一个小事务的SQL,确保另一个完成.上面是死锁的概念,而在MySQL ...
- h5解决移动端上滑卡顿问题
select{ -webkit-overflow-scrolling: touch;/*解决移动端滑动卡顿问题*/ -webkit-transform: translateZ(0px);/*开启GPU ...
- sqlserver 添加服务器链接 跨服务器访问数据库
转载地址1:https://www.cnblogs.com/wanshutao/p/4137994.html //创建服务器链接 转载地址2:https://www.cnblogs.com/xulel ...
- 不立flag了……
当天刚说再也不想下这游戏了,后来和女友聊了会天视了会屏又动摇了..后悔和她那么计较这些小事,可能玩游戏时生气时就想不起来那么多事了吧..于是游戏过两天就又下回来了.. 这两天培训课程也是很快的感觉,昨 ...
- Oracle 12c的可插拔数据库PDB
1. 默认安装之后会有一个可插拔数据库:pdborcl 2. 启动根容器: [oracle@eric ~]$ export ORACLE_SID=orcl [oracle@eric ~]$ sqlpl ...
- Windows 平台 (UWP)应用设计
Make Your Apps Cooperate with Cross-App Communication : https://rewards.msdn.microsoft.com/Challeng ...
- HDU 6129 Just do it
题意:给你一个包含n个数的序列A和一个数m,序列B中的数是序列A经过异或得到的,比如:b[i]=a[1]^a[2]^…..^a[i].现在让你求经过m次异或后,序列B的值. 思路:这题其实和杨辉三角 ...
- python学习 day14 (3月19日)----
04 json # 1. 用于多种语言 交互 编程语言通用数据 # 内置的 不需要安装直接导入使用 import json # 导入 # # dumps loads dump load # dic = ...
- 19 模块之shelve xml haslib configparser
shelve 什么是shelve模块 也是一种序列化方式使用方法 1.opne 2.读写 3.close特点:使用方法比较简单 提供一个文件名字就可以开始读写 读写的方法和字典一致 你可以把它当成带有 ...