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的內在內容大小需要多一點。圖像約束只是設置在每一邊,以便填充。 –
什麼是簡單的解決方案...我所要做的就是擺脫常量,現在它完美。 –