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) 从登录界面-->忘记密码输入手机号- ...
随机推荐
- Android.InstallDevelopmentEvn
1. 如何搭建Android Application的开发环境 http://blog.csdn.net/yzhj2005/article/details/6980676 2. 在Mac OS X系统 ...
- RNA测序相对基因表达芯片有什么优势?
RNA测序相对基因表达芯片有什么优势? RNA-Seq和基因表达芯片相比,哪种方法更有优势?关键看适用不适用.那么RNA-Seq适用哪些研究方向?是否您的研究?来跟随本文了解一下RNA测序相对基因表达 ...
- System.Runtime.InteropServices.COMException: 检索 COM 类工厂中 CLSID 为 {0002E510-0000-0000-C000-000000000046} 的组件时失败,原因是出现以下错误: 80040154
这个问题困恼我好几天了,今天终于解决. 开始我在网上左百度右google,都没搜到最终的解决方案,今天我把解决方案贴出来,以供大家分享! 网上有些是报80070005错误的,跟我这个80040154错 ...
- JeeSite 4.0
http://jeesite.com/ JeeSite 是一个 Java EE 企业级快速开发平台,基于经典技术组合(Spring Boot.Spring MVC.Apache Shiro.MyBat ...
- [Robot Framework] 通过SikuliLibrary可以获取到图片,但是点击失效
执行时,可以看到鼠标已经移动到图片上了,但是点击失效,日志也没有报错 后来发现是windows权限的问题. 通过打开Control Panel->System and Security-> ...
- Subarray Sum Equals K LT560
Given an array of integers and an integer k, you need to find the total number of continuous subarra ...
- *args 和**kwargs 的溯源
*args:arguments:表示参数,代表一个tuple**kwargs:表示关键字参数,代表一个dict 也就是keyword args.keyword就表示字典,也就是关键字.为什么叫关键字. ...
- android 使用UDP发送数据 DatagramSocket 创建对象为null
DatagramSocket socket=null; try { socket = new DatagramSocket(); //这里创建对象为空 } catch (SocketExceptio ...
- iframe高度自适应实现方案
iframe高度动态自适应,一直是个头疼的问题,今天我们从事件监听这个角度,来实现iframe高度实时更新. 方案一:监听iframe体的点击事件 <iframe src="casca ...
- Spring Boot学习笔记:JavaMailSender发送邮件
项目中经常会有这样的需求,用户注册成功,需要给用户发送一封邮件.邮件需要有一定格式和样式.本次例子中用freemarker做样式,其他的模版引擎类似. 首先Spring Boot项目,项目结构如下 在 ...