我已经尝试了很多带完成按钮的数字键盘,但在SWIFT 2.0中找不到正确的答案.
您可以使用工具栏在键盘上方添加完成按钮
override func viewDidLoad() { super.viewDidLoad() let tooBar: UIToolbar = UIToolbar() tooBar.barStyle = UIBarStyle.BlackTranslucent tooBar.items=[ UIBarButtonItem(barButtonSystemItem: UIBarButtonSystemItem.FlexibleSpace, target: self, action: nil), UIBarButtonItem(title: "Done", style: UIBarButtonItemStyle.Done, target: self, action: "donePressed")] tooBar.sizeToFit() yourTextFeild.inputAccessoryView = tooBar } func donePressed () { yourTextFeild.resignFirstResponder() }
它看起来像这样