Created
June 13, 2016 03:57
-
-
Save ruddfawcett/bb993a1783fb0747d219cef6027c2486 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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