【发布时间】:2018-07-28 18:26:45
【问题描述】:
我有一个文本字段,我将其设置为 >= 50 的高度。在文本字段下方,我有 uiview,它锚定在文本字段的底部。一旦文本字段超过 50 点高度,我希望它向下推动 uiview,以便文本继续向下。现在发生的事情是它撞到了自身的底部,而不是向下推动 uiview,而是向上滚动文本并且 uiview 没有移动。
一旦文本字段超过 50 点高度,我怎样才能让文本字段停止向上滚动,而是将 uiview 向下推?我可以使用行数为 0 的文本字段,但我宁愿使用文本字段。
// imageView is pinned to the top of the screen
textView.topAnchor.constraint(equalTo: iamgeView.bottomAnchor, constant: 32).isActive = true
textView.leadingAnchor.constraint(equalTo: view.safeAreaLayoutGuide.leadingAnchor, constant: 8).isActive = true
textView.trailingAnchor.constraint(equalTo: view.safeAreaLayoutGuide.trailingAnchor, constant: -8).isActive = true
textView.heightAnchor.constraint(greaterThanOrEqualToConstant: 50).isActive = true
bottomLine.topAnchor.constraint(equalTo: textView.bottomAnchor, constant: 8).isActive = true
bottomLine.leadingAnchor.constraint(equalTo: view.safeAreaLayoutGuide.leadingAnchor, constant: 8).isActive = true
bottomLine.trailingAnchor.constraint(equalTo: view.safeAreaLayoutGuide.trailingAnchor, constant: -8).isActive = true
bottomLine.heightAnchor.constraint(equalToConstant: 0.5).isActive = true
【问题讨论】:
标签: ios swift uiview uitextview nslayoutconstraint