Gal*_*her 36
如果您使用.buttonStyle(style:)修饰符并想要更改背景颜色,请使用.tint(tint:)而不是.background(alignment:content)。例如,您可以通过以下方式将.borderedProminent按钮样式更改为绿色:
Button("Press Me!") {
//stuff to do
}
.buttonStyle(.borderedProminent)
.tint(.green)
Run Code Online (Sandbox Code Playgroud)
Tua*_*yen 18
您可以在没有任何容器的情况下直接向按钮添加修改项(例如:组)
Button(action: {}) {
Text("Click me!")
}
.padding()
.foregroundColor(.white)
.background(Color.red)
Run Code Online (Sandbox Code Playgroud)
希望能帮到人!
小智 9
Button(action: {self.buttonTapped()}) {
Text("Button")
.padding(.all, 12)
.foregroundColor(.white)
.background(Color.red)
}
Run Code Online (Sandbox Code Playgroud)
这就是整个 bg 可点击的方式
Group {
Button(action: { }) {
Text("Button Text!")
.padding()
}
}
.background(Color.black)
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1311 次 |
| 最近记录: |