Skip to content

Instantly share code, notes, and snippets.

@ruddfawcett
Created June 13, 2016 03:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ruddfawcett/bb993a1783fb0747d219cef6027c2486 to your computer and use it in GitHub Desktop.
Save ruddfawcett/bb993a1783fb0747d219cef6027c2486 to your computer and use it in GitHub Desktop.
import UIKit
class ViewController: UIViewController {
let keyboard = KeyboardControl()
override func viewDidLoad() {
super.viewDidLoad()
self.title = "Timepad"
self.view.backgroundColor = UIColor.whiteColor()
let gesture = UITapGestureRecognizer(target: keyboard, action: #selector(keyboard.show))
self.view.addGestureRecognizer(gesture)
}
}
class KeyboardControl : UIControl, UIKeyInput {
init() {
super.init(frame: CGRectZero)
}
override func canBecomeFirstResponder() -> Bool {
return true
}
required init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
}
func show() {
becomeFirstResponder()
}
// MARK: UIKeyInput
func hasText() -> Bool {
return true
}
func insertText(text: String) {
print(text)
}
func deleteBackward() {
return
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment