Guest User

Untitled

a guest
Jun 23rd, 2018
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.74 KB | None | 0 0
  1. protocol SwitchKeyboardDelegate: class {
  2. func switchKeyboard()
  3. }
  4.  
  5. class CustomAccessoryView: UIView {
  6.  
  7. weak var delegate: SwitchKeyboardDelegate!
  8.  
  9. required init?(coder aDecoder: NSCoder) {
  10. super.init(coder: aDecoder)
  11. initializeSubviews()
  12. }
  13.  
  14. override init(frame: CGRect) {
  15. super.init(frame: frame)
  16. initializeSubviews()
  17. }
  18.  
  19. func initializeSubviews() {
  20. // 不需包括xib檔名
  21. let xibFileName = "CustomAccessoryView"
  22. let view = Bundle.main.loadNibNamed(xibFileName, owner: self, options: nil)![0] as! UIView
  23. self.addSubview(view)
  24. view.frame = self.bounds
  25. }
  26.  
  27. @IBAction func switchBtnTap(){
  28. self.delegate.switchKeyboard();
  29. }
  30. }
Add Comment
Please, Sign In to add comment