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) 从登录界面-->忘记密码输入手机号- ...
随机推荐
- iOS.CodeSign
Inside Code Signing 1. Code Signing需要的基础组件: 证书,私钥 As an iOS developer, chances are you have a certif ...
- Python.Books
Flask 1. Flask Web Development Miguel Grinberg April 2014 2. Flask Framework Cookbook Shalabh Aggarw ...
- How do I configure a Wired Ethernet interface
1.In order to configure the Wired Ethernet interface the MDI must be connected to the PC using the U ...
- .net委托
今天要学的是委托 委托的基本形式 直接上代码 public delegate int AddDelegate(int x,int y); class Program { static void Mai ...
- 用VS2010打开VS2012项目
1.修改解决方案文件,即.sln文件: 用记事本打开.sln文件,把其中的 Microsoft Visual Studio Solution File, Format Version 12.00 # ...
- YII配置mysql读写分离
Mysql 读写分离 YIi 配置 <?php return [ 'class' => 'yii\db\Connection', 'masterConfig' => [ // 'ds ...
- (转贴)fusionCharts属性参考API
一.FusionCharts的分类 关于FusionCharts的基本介绍我就不在这里浪费篇幅了,想了解的朋友自己去www.baigoogedu.com里面找吧.我就说说FusionCharts的官方 ...
- 操作Float的BigDecimal加减乘除
bignum3 = bignum1.add(bignum2); //加 bignum3 = bignum1.subtract(bignum2); 减 bignum3 = bignum1.m ...
- Gym - 100735E Restore
E - Restore 题意:输入一个n,输入一个对角线空缺(为0)的n*n的矩阵,要求每一行每一列和对角线的和相同,输出完整的矩阵. 解法:设每一行的和都是sum,用一个h[]数组存每一行的和.则可 ...
- RabbitMQ c#版实现(转)
出处:https://www.cnblogs.com/hanfan/p/9842301.html 网上很多人已经总结的很好了,比如今天看到的这个.https://www.cnblogs.com/Lip ...