首页 编程 软件学院 查看内容

一款实用的数字定制键盘(支持身份证及数字输入)

2016-9-3 14:49 1119 0

摘要: IDCardKeyboardIDCardKeyboardA custom digital keyboard for idcard:eyes:See also:CocoaPodsCocoaPodsis a dependency manager for Cocoa projects. You can install it with the following command:$ gem install ...

IDCardKeyboard

IDCardKeyboard

A custom digital keyboard for idcard

:eyes: See also:

CocoaPods

CocoaPods is a dependency manager for Cocoa projects. You can install it with the following command:

$ gem install cocoapods

CocoaPods 0.39.0+ is required to build IDCardKeyboard 3.0.0+.

To integrate IDCardKeyboard into your Xcode project using CocoaPods, specify it in your Podfile :

source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '9.0'
use_frameworks!

target '<Your Target Name>' do
    pod 'IDCardKeyboard', '~> 1.0.8'
end

Then, run the following command:

$ pod install

:book: Usage

import UIKit

class ViewController: UIViewController {
    let textField: UITextField = UITextField()
    let fieldNext: UITextField = UITextField()
    var fields: [UITextField] = []


    override func viewDidLoad() {
        super.viewDidLoad()

        view.backgroundColor = .orangeColor()
        textField.frame = CGRect(x: 80, y: 400, width: 200, height: 30)
        textField.borderStyle = .RoundedRect
        textField.clearButtonMode = .WhileEditing
        textField.becomeFirstResponder()
        view.addSubview(textField)
        fieldNext.frame = CGRect(x: 80, y: 500, width: 200, height: 30)
        fieldNext.borderStyle = .RoundedRect
        fieldNext.placeholder = "nextField"
        view.addSubview(fieldNext)
        textField.becomeFirstResponder()
        let keyboard = IDCardKeyboard(view: view)
        keyboard.style = .Number
        keyboard.customDoneButton("我去", titleColor: .blackColor(), theme: .orangeColor())
        textField.inputView = keyboard
    }

    override func viewDidLayoutSubviews() {
        super.viewDidLayoutSubviews()
    }

    override func touchesBegan(touches: Set<UITouch>, withEvent event: UIEvent?) {
            UIApplication.sharedApplication().keyWindow?.endEditing(true)
    }
}

### :key: Basics Swift 2.2

声明:文章版权归原作者所有 部分文章转自互联网 如有侵权请联系 [邮箱地址] 删除

路过

雷人

握手

鲜花

鸡蛋

最新评论

返回顶部