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

时间:2015-06-16 17:09:09

标签: swift ios9

我在许多应用中都看到过,但我无法在线找到有用的教程。 我怎样才能在Swift中实现类似的东西?

enter image description here

1 个答案:

答案 0 :(得分:1)

好的,您需要在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

这一切都在那里完成,但我强烈认为你不应该在导航栏中添加登录表单,这是非常不切实际的。

相关问题