当用户在inputAccessoryView中点击“附加”按钮时,我想通过键盘创建一个简单的视图。像这样:
有简单的方法吗?或者我应该创建我的自定义键盘?
您可以将该新子视图添加到您的应用程序窗口。
func attach(sender : UIButton) { // Calculate and replace the frame according to your keyboard frame var customView = UIView(frame: CGRect(x: 0, y: self.view.frame.size.height-300, width: self.view.frame.size.width, height: 300)) customView.backgroundColor = UIColor.redColor() customView.layer.zPosition = CGFloat(MAXFLOAT) var windowCount = UIApplication.sharedApplication().windows.count UIApplication.sharedApplication().windows[windowCount-1].addSubview(customView); }