【问题标题】:Button inside textview文本视图内的按钮
【发布时间】:2018-08-02 02:16:31
【问题描述】:

在网上搜索了很久,我仍然在为这个问题苦苦挣扎。

我正在 swift 中为 iOS 开发一个应用程序,我需要在文本视图(而不是文本字段)中放置一个按钮。 该按钮应始终位于 textview 的右下角,并且当用户键入文本时 textview 展开时它不必移动。 当然,文本不应该越过按钮。

我为此找到了几个解决方案,但与文本字段相关。 同样的方法似乎对我不起作用。

有人可以帮忙吗?

【问题讨论】:

  • 最棘手的事情是防止文本与按钮重叠。也许你应该看看exclusionPaths,就像这里:littlebitesofcocoa.com/…

标签: ios swift xcode button textview


【解决方案1】:

为什么不拥有自己的容器来容纳这两个组件。

Main View
 - > TextView     
 - > Button

添加所需的约束。大致如下:

**button**: height constraint; bottom constraint to container.
**TextView** top + bottom constraint to container
**Main View** height constraint (and adjust it based on button action and text)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-05-23
    • 1970-01-01
    • 2017-08-28
    • 2015-11-04
    • 2013-07-31
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多