Post

Replies

Boosts

Views

Activity

Reply to watchOS Button background color in SwiftUI?
I've managed to achieve this by building upon the advice to use BorderedButtonStyle, however I also call the .opacity(_:) method of the Color with the value way higher than 1.0: Button("My Button") { 		// Do something here } .buttonStyle(BorderedButtonStyle(tint: Color.blue.opacity(255))) Works great for me in Xcode 12.3 with the watchOS 7.2 simulator. I didn't test it on the older versions of watchOS or on a real device. I played with the different values of opacity and seems like the color changes when the value is in range 0...10, but anything larger than 10 always yields the same color. I used 255 because I like this number. Unfortunately, the Color.opacity(_:) - https://developer.apple.com/documentation/swiftui/color/opacity%28_:%29 method is not documented as of December, 2020, so I have no idea whether this is an expected behavior or just a dirty hack that will break in the future releases. Would be great to have some insights on that from the SwiftUI team.
Dec ’20