Last active
June 22, 2018 01:46
-
-
Save jamesaq12wsx/9747fa9b81efa11012e42eeabb99bd1f to your computer and use it in GitHub Desktop.
[swift]建立App內部鍵盤
This file contains 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
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