[英]How to remove left padding from UIButton?
您需要使用一些負左值調整imageEdgeInsets和titleEdgeInsets。 然后它會轉移到左邊。 我測試了它的工作原理。 100是臨時值。
button.imageEdgeInsets = UIEdgeInsets(top: 0.0, left: -100.0, bottom: 0.0, right: 0.0)
button.titleEdgeInsets = UIEdgeInsets(top: 0.0, left: -100.0, bottom: 0.0, right: 0.0)
如果它不起作用,請告訴我。
此行可以解決您的問題
button.titleEdgeInsets.left = 0 // add left padding.
或者也許你可以在這種情況下使用負值
還有這種方式:
button.titleEdgeInsets = UIEdgeInsets(top: 0.0, left: 0.0, bottom: 0.0, right: 0.0)
試試不同的價值!
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.