请告诉我这个 UI 名称是如何命名的

瓦夫核弹

这个界面名称是什么?
它就像是在键盘上粘贴...
就像一个信使应用程序 UITextField...
我不知道这个 UI 名称。
那是什么?

在此处输入图片说明

普拉尚·图卡迪亚

这是通过输入附件视图完成的 UIViewController

使用您的文本作为输入附件视图,UIViewController因此从故事板中删除该底部视图

在您的视图控制器中添加以下内容

var viewAcc: UIView?
var sendButton: UIButton!
var inputTextField: UITextField!

override var inputAccessoryView: UIView? {
    return viewAcc
}

override var canBecomeFirstResponder: Bool {
    return true
}

在视图中加载方法添加以下代码
注意:请根据您的要求更改约束

    viewAcc = UIView(frame: CGRect(x: 0, y: 0, width: UIScreen.main.bounds.width, height: 44))
    viewAcc?.backgroundColor = UIColor.white
    inputTextField = UITextField (frame: CGRect(x:8, y:0, width:UIScreen.main.bounds.width, height: 44 ))
    inputTextField.inputAccessoryView = nil
    inputTextField.delegate = self as? UITextFieldDelegate
    inputTextField.placeholder = "Enter message..."
    viewAcc?.backgroundColor = .white
    viewAcc?.addSubview(inputTextField);

    let topBorderView = UIView()
    topBorderView.backgroundColor = UIColor(white: 0.5, alpha: 0.5)
    viewAcc?.addSubview(topBorderView)
    viewAcc?.addConstraintsWithFormat(format: "H:|[v0]|", views: topBorderView)
    viewAcc?.addConstraintsWithFormat(format: "V:|[v0(0.5)]", views: topBorderView)

    sendButton = UIButton(type: .system)
    sendButton.isEnabled = true
    sendButton.titleLabel?.font = UIFont.systemFont(ofSize: 16)
    sendButton.setTitle("Send", for: .normal)
    sendButton.contentEdgeInsets = UIEdgeInsets(top: 8, left: 8, bottom: 8, right: 8)
    sendButton.addTarget(self, action: #selector(handleSend), for: .touchUpInside)
    viewAcc?.addSubview(sendButton)

    inputTextField.translatesAutoresizingMaskIntoConstraints = false
    sendButton.translatesAutoresizingMaskIntoConstraints = false
    viewAcc?.addConstraint(NSLayoutConstraint(item: inputTextField, attribute: .left, relatedBy: .equal, toItem: viewAcc, attribute: .left, multiplier: 1, constant: 8))
    viewAcc?.addConstraint(NSLayoutConstraint(item: inputTextField, attribute: .top, relatedBy: .equal, toItem: viewAcc, attribute: .top, multiplier: 1, constant: 7.5))
    viewAcc?.addConstraint(NSLayoutConstraint(item: inputTextField, attribute: .right, relatedBy: .equal, toItem: sendButton, attribute: .left, multiplier: 1, constant: -2))
    viewAcc?.addConstraint(NSLayoutConstraint(item: inputTextField, attribute: .bottom, relatedBy: .equal, toItem: viewAcc, attribute: .bottom, multiplier: 1, constant: -8))
    viewAcc?.addConstraint(NSLayoutConstraint(item: sendButton, attribute: .right, relatedBy: .equal, toItem: viewAcc, attribute: .right, multiplier: 1, constant: 0))
    viewAcc?.addConstraint(NSLayoutConstraint(item: sendButton, attribute: .bottom, relatedBy: .equal, toItem: viewAcc, attribute: .bottom, multiplier: 1, constant: -4.5))

转到 Storyboard 选择您的 tableview 并将键盘关闭模式设置为交互式就是这样

现在您可以用手指拖动以关闭键盘和文本字段

编辑 IPHONE X 支持

lazy var viewAcc: SafeAreaInputAccessoryViewWrapperView = {
    return SafeAreaInputAccessoryViewWrapperView(for: button)
}()

这是完整的演示https://github.com/29satnam/InputAccessoryView

希望它有帮助

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

请告诉我如何制作跟随角色的UI

Pascal,请告诉我这个循环是如何工作的

谁能告诉我这个密码的名称?

请告诉我如何编写nuxt插件'printd'

PHP 请告诉我如何访问对象键

你能告诉我这个 Solidity 是如何工作的吗?

请告诉我所附图像中描述的这种视图的名称

请告诉我如何增加字数限制而不是字符数限制

应用android5.1.1 Proguard后会发生VerifyError。请告诉我如何解决

请告诉我如何在JS中重复此过程?

请告诉我如何在 CSS 中使用变量作为属性值

我如何让这个 RPG 工作,它告诉我 Y 和 N 没有定义

这个错误试图告诉我什么,我该如何解决?

有人能告诉我如何摆脱这个错误吗

如何在C语言中调用另一个用户定义函数中的用户定义函数?这个程序有错误...请告诉我那是什么?

如何解决这个问题请告诉

如何进行USART通信请告诉我进行USART通信应注意的一切

你好,请告诉我如何将 ArrayList 发送到另一个活动

有人可以告诉我这个正则表达式如何匹配任何内容吗?

谁能告诉我如何删除从 CVPR 纸背页模板上写的这个侧线编号和所有蓝色?

WordPress如何告诉我的CSS版本

谁能告诉我如何实现?

我退出应用程序后遇到此错误(在onBackpressed块),我应该继续执行此错误,否则请告诉我如何解决此错误

传递二维数组时,我的打印功能无法正确打印,请告诉我如何正确打印其所有值。是我的语法吗?

我们可以为<input type = file />设置值吗?如果是,请告诉我们如何设置

PHP strtok()如果我理解这个权利,请告诉我

任何人都可以告诉我如何在颤振中制作这种布局,因为我是颤振的新手,我陷入了这个困境

请告诉我为什么这个对象迭代器只允许记录一次

带有Ogen的magento REST api的POSTMAN rest客户端。如何获得令牌和令牌秘密?,请逐步告诉我每个过程