[英]UIStackView multiline buttons overlapping
我試圖將UIButtons動態添加到UIStackView ,但是遇到一些奇怪的行為。 由於按鈕內的文本也是動態的,因此它應該是多行的(默認情況下不是)。 所以我這樣設置中斷模式:
UIButtons
UIStackView
button.titleLabel?.lineBreakMode = NSLineBreakMode.byWordWrapping stackView.addArrangedSubview(button)
結果看起來像這樣(我為按鈕設置了不同的背景色以更好地說明問題):
文本超出按鈕的邊界,並與其他視圖重疊。 如何解決?
UIStackView是從以下簡單的xib加載的:
提前致謝
titleLable不受按鈕范圍的限制,這就是問題所在。 您應該擴展UIButton並覆蓋layoutSubviews或internalContentSize,或者僅嘗試注入約束。
[英]Multiline label in UIStackView with UIScrollview
[英]UIStackView in UITableViewCell with multiline UILabels
[英]ios - UIStackView and multiline UILabels
[英]UIStackView and truncated Multiline UILabels
[英]Multiline label in UIStackView
[英]Overlapping Views in UIStackView
[英]UIStackView distribution and alignment of a multiline UILabel
[英]Proportional resizing of buttons in UIStackView
[英]UIStackView add overlapping views in Storyboard
[英]UIStackView resetting properties of buttons inside it
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.