键盘顶部的工具栏,带有完成的按钮和文本字段导航

Toolbar in Keyboard top with done Button and textfield Navigation

我在很多应用程序中都看到过,但我在网上找不到有用的教程。 我怎样才能在 Swift 中实现类似的东西?

好的,所以您需要向 NavigationBar 添加一个 UITextField。这是应该对您有帮助的代码:

var textField=UITextField()
//Configure the size and other properties..
self.navigationItem.titleView = textField

对于右侧的按钮,您应该这样做:

var button = UIBarButtonItem(title: "FOO", style: UIBarButtonItemStyle.Plain, target: self, action: "FOO")
self.navigationItem.rightBarButtonItem = button

到这里就全部完成了,但我强烈认为您不应该在导航栏中添加登录表单,这是非常不切实际的。