Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Button has two different colors, even if only specified one

I want to fit a button to the whole screen of my apple watch. But there is a lighter red and a dark red like in this picture. enter image description here

This is my code: I want the whole screen to have only one color if this is possible. Thanks

Button(action: {
                Task {
                    if (!muteWatch) {
                        WKInterfaceDevice.current().play(.failure)
                    }
                    Task {
                        await isWorkingSince()
                    }
                }
            }, label: {
                Text("Stop ".localized() + stopTimeString).padding().frame(
                    minWidth: 0,
                    maxWidth: .infinity,
                    minHeight: 0,
                    maxHeight: .infinity,
                    alignment: .topLeading
                  ).background(Color.red)
            }).padding().frame(
                minWidth: 0,
                maxWidth: .infinity,
                minHeight: 0,
                maxHeight: .infinity,
                alignment: .topLeading
              ).background(Color.red)

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

You need plain button style, like

    Button(action: {}) {
        Text("Hello, World!")
        .frame(maxWidth: .infinity, maxHeight: .infinity)
        .background(.red)
    }
    .buttonStyle(.plain)    // << here !!

Tested with Xcode 13.4 / watchOS 8.5

demo

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading