无法通过编程设置UILabel / UITextView的高度

时间:2018-08-06 16:30:34

标签: ios swift uilabel uitextview

我有一个ViewController,其中包含标题,图像和长文本。我希望将它作为一个整体滚动而不是唯一的文本。

我正在根据其文字计算尺寸。计算正确,但我尝试使用该代码。

newsDetailTextView.heightAnchor.constraint(equalToConstant:newsDetailString.height(containerWidth: newsDetailTextView.frame.size.width)).isActive = true

它的大小不变。

怎么了?

能给我指路吗?

BR,

Erdem

2 个答案:

答案 0 :(得分:0)

通过故事板将textView的scrollEnabled属性设置为false或取消选中。

答案 1 :(得分:-1)

如果您想使用约束方式,建议您阅读here

Listing 13-1中检查Apple的官方documentation,其中使用了heightAnchor。

相关问题