什么是自定义键盘?
自定义键盘是一个简单快速的自定义数字键盘框架。总有适合您的键盘。
我们的演示截屏
需求
- iOS 11.2
- Xcode 9.2
- Swift 4.0.2+
安装
CocoaPods是一个Cocoa项目的依赖管理器。您可以使用以下命令安装它
$ gem install cocoapods
只需将Customkeyboard
文件夹添加到您的项目中。
或者使用Podfile通过CocoaPods
pod 'Customkeyboard'
Swift 4.0.3:
platform :ios, '11.2'
target '<Your Target Name>' do
use_frameworks!
pod 'Customkeyboard'
end
然后运行以下命令
$ pod install
修订
- 添加按钮音效
- 添加长按压删除
示例
import UIKit
import Customkeyboard
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
view.backgroundColor = UIColor.gray
example()
}
/// 例子
private func example() {
/// 文本框
let textField = UITextField(frame: CGRect(x: 100, y: 120, width: 200, height: 35))
textField.backgroundColor = UIColor.white
view.addSubview(textField)
/* -- CustomKeyboard --- */
let keyboard = CustomKeyboard(view, field: textField)
keyboard.style = .number
keyboard.whetherHighlight = true
keyboard.frame.size.height = 300
keyboard.customDoneButton(title: "确定", titleColor: .white, theme: lightBlue, target: self, callback: nil)
textField.becomeFirstResponder()
}
}