I have a Button. I want to set custom background color for highlighted state. How can I do it in SwiftUI?
Button(action: signIn) {
Text("Sign In")
}
.padding(.all)
.background(Color.red)
.cornerRadius(16)
.foregroundColor(.white)
.font(Font.body.bold())
Run Code Online (Sandbox Code Playgroud) 对于 SwiftUI,默认按钮行为相当于 UIKit 的“向上触摸”,当您的手指触摸按钮时激活,然后在按钮范围内抬起。
有什么方法可以将其更改为“触摸”,以便在您的手指触摸按钮时立即运行动作关闭?