Latest 1.0.0
Homepage https://github.com/wxxsw/GSCaptchaButton
License MIT
Platforms ios 8.0
Authors

功能

  • 倒计时
  • 自动禁用/启用按钮
  • 自定义文字

使用方法

无论是自定义控件还是 xib,将继承自 UIButton 改为 GSCaptchaButton

captchaBtn.setTitle("获取验证码", forState: .normal)
captchaBtn.setTitle("正在获取验证码:second秒", forState: .disabled) 

// 注意:second为关键字,会在运行时替换为秒数,所以可以自定义你想要的文本,如:
// captchaBtn.setTitle("second秒后重试", forState: .disabled)
// captchaBtn.setTitle("(second)重新获取", forState: .disabled)

开始倒计时

captchaBtn.maxSecond = 30 // 默认为60
captchaBtn.countdown = true

手动结束

captchaBtn.countdown = false

判断是否处于倒计时状态

captchaBtn.countdown  // return Bool

要求

Master

  • iOS 8.0+
  • Xcode 10 (Swift 4.2)

安装

CocoaPods:

Podfile 中增加:
pod "GSCaptchaButton"

手动

GSCaptchaButton.swift 文件拖入你的项目

Latest podspec

{
    "name": "GSCaptchaButton",
    "version": "1.0.0",
    "summary": "u4e3au666eu901au6309u94aeu589eu52a0u9a8cu8bc1u7801u5012u8ba1u65f6u529fu80fduff0cu4e0du5f71u54cdu6309u94aeu6837u5f0f",
    "homepage": "https://github.com/wxxsw/GSCaptchaButton",
    "license": "MIT",
    "authors": {
        "Gesen": "[email protected]"
    },
    "source": {
        "git": "https://github.com/wxxsw/GSCaptchaButton.git",
        "tag": "1.0.0"
    },
    "source_files": "GSCaptchaButton/Classes/**/*",
    "platforms": {
        "ios": "8.0"
    },
    "swift_version": "4.2"
}

Pin It on Pinterest

Share This