0
我使用这个代码来创建假设,以适应一个UIView容器内一个UITextView:UITextView的不拟合内容
// Make the cellTextView.
let cellTextView = UITextView()
cellTextView.backgroundColor = UIColor.clearColor()
cellTextView.translatesAutoresizingMaskIntoConstraints = false
cellTextView.scrollEnabled = false
superview.addSubview(cellTextView)
// Constrain the cellTextView.
cellTextView.topAnchor.constraintEqualToAnchor(superview.topAnchor, constant: 8).active = true
cellTextView.bottomAnchor.constraintEqualToAnchor(superview.bottomAnchor, constant: -8).active = true
cellTextView.leadingAnchor.constraintEqualToAnchor(superview.leadingAnchor, constant: 8).active = true
cellTextView.trailingAnchor.constraintEqualToAnchor(superview.trailingAnchor, constant: -8).active = true
我已经尝试了很多不同的东西,但没有任何修复它。 任何建议将不胜感激。
什么是你的形象限制? – CBortoli
图像不影响文本视图。这是因为层次结构如下所示:ImageView(Background),ContainerBar(在ImageView之上叠加),UITextView(在ContainerBar之内)。 ContainerBar根据需要展开和缩小以适应UITextView,但我猜测UITextView的内在内容大小需要多一点。图像约束只是设置在每一边,以便填充。 –
什么是简单的解决方案...我所要做的就是摆脱常量,现在它完美。 –