gpt4 book ai didi

ios - UIButton 未使用分配的文本展开

转载 作者:搜寻专家 更新时间:2023-11-01 06:18:26 25 4
gpt4 key购买 nike

我在屏幕上有一个 UIButton。 UIButton 没有宽度限制。我喜欢将我的 UIButton 扩展为指定的文本。但这是结果:

enter image description here

这里是实现:

self.translatedPhraseButton.setTitle(self.selectedPhrase.translatedPhrase, for: .normal)
self.translatedPhraseButton.sizeToFit()
self.translatedPhraseButton.titleEdgeInsets = UIEdgeInsets(top: 0.0, left: 5.0, bottom: 0.0, right: 5.0)
self.translatedPhraseButton.layer.cornerRadius = 10.0
self.translatedPhraseButton.layer.masksToBounds = true
self.translatedPhraseButton.backgroundColor = UIColor(fromHexString: "2aace3")

最佳答案

所以,我终于用一行代码解决了我的问题:

 self.translatedPhraseButton.contentEdgeInsets = UIEdgeInsets(top: 0.0, left: 15.0, bottom: 0.0, right: 15.0) 

关于ios - UIButton 未使用分配的文本展开,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39173750/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com