Skip to content

Instantly share code, notes, and snippets.

@jamesaq12wsx
Last active June 22, 2018 01:46
Show Gist options
  • Save jamesaq12wsx/9747fa9b81efa11012e42eeabb99bd1f to your computer and use it in GitHub Desktop.
Save jamesaq12wsx/9747fa9b81efa11012e42eeabb99bd1f to your computer and use it in GitHub Desktop.
[swift]建立App內部鍵盤
protocol SwitchKeyboardDelegate: class {
func switchKeyboard()
}
class CustomAccessoryView: UIView {
weak var delegate: SwitchKeyboardDelegate!
required init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
initializeSubviews()
}
override init(frame: CGRect) {
super.init(frame: frame)
initializeSubviews()
}
func initializeSubviews() {
// 不需包括xib檔名
let xibFileName = "CustomAccessoryView"
let view = Bundle.main.loadNibNamed(xibFileName, owner: self, options: nil)![0] as! UIView
self.addSubview(view)
view.frame = self.bounds
}
@IBAction func switchBtnTap(){
self.delegate.switchKeyboard();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment