我想使用 UIButton.configuration contentInsets 為 Swift 中的按鈕添加一些填充,但它并沒有真正做任何事情。
難道我做錯了什么?
我的按鈕創建是:
lazy var botonDescarga : UIButton = {
let boton = UIButton(frame: .zero)
boton.setTitle("Descargar todo", for: .normal)
boton.backgroundColor = .white
boton.setTitleColor(UIColor(.black), for: .normal)
boton.layer.cornerRadius = 5
boton.layer.borderWidth = 1
boton.configuration?.contentInsets = NSDirectionalEdgeInsets(top: 10, leading: 10, bottom: 10, trailing: 10)
return boton
}()
uj5u.com熱心網友回復:
在這一行let boton = UIButton(frame: .zero)按鈕型別是.system所以配置不起作用,你必須改變配置型別
boton.configuration = UIButton.Configuration.filled() // or filled,tinted,gray
如果您不發送其中一個boton.configuration?是零,那為什么它不起作用
不要像評論中所說的那樣將兩者一起使用選擇一個。例如,如果您像我說的那樣更改它,并且您想設定類似的字體
button.font = ...將不起作用。選擇一個并使用
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/486942.html
