'UIButton always truncate text on iOS 15
After update to xcode 13 / ios 15. I see, that always text is truncated on UIButton with non fix size. The text is delivered from a PushRelay (RxSwift).
See UIButton's on a horizontal UIStackView.
The Code is the following
let tagButton = UIButton()
addSubview(tagButton)
tagButton.layer.cornerRadius = 16
tagButton.layer.masksToBounds = true
tagButton.titleEdgeInsets = UIEdgeInsets(top: 8, left: 16, bottom: 8, right: 16)
tagButton.snp.makeConstraints({
$0.edges.equalToSuperview()
})
The Text is deliverd by:
bag.insert(
viewModel.outputs.titleAttrText
.drive(tagButton.rx.attributedTitle(for: .normal))
)
Solution 1:[1]
I'm seeing this problem inside a UIStackView.
Switching from titleEdgeInsets to contentEdgeInsets fixed the problem for me.
Solution 2:[2]
The solution is the titleEdgeInsets property.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Pacificana |
| Solution 2 | Mark Rotteveel |
