I developed a button appearance using SwiftUI for an iOS app — the code (reduced to a minimum, for the example):
struct ButtonView: View {
var body: some View {
Button("ZnX") { }
.font(.custom("Gorton-Normal-120", size: 96))
.foregroundColor(.red)
.background(Color(.darkGray))
.frame(width: 320, height: 320)
.background(Color(.darkGray))
}
}
. . and the appearance of the iOS button:
In macOS, the same code renders quite differently:
- the
.foregroundColor(.red)
has no effect .. - neither does the
.background(Color(.darkGray))
.. - and the
n
doesn’t generate a newline ..
Before writing this I took a look at a similar question at SwiftUI customized text field in OSX but that relates to a TextField
, not a Button
.
I also read Issue with Buttons in SwiftUI on MacOS which, right at the end, suggests Button
on macOS is broken and to just use Text
with an onTapGesture
..
Maybe that’s the answer, but I’m leaving this question here in case it helps someone else wandering into the same inconsistency, and, also, in case someone has some insight or better approach.