1

For some reason my background is showing over my text label. I have the background as white and text as red, but for some reason the white background covers the text. I am referring to the "Tap me" button. In preview it shows correctly however in the simulator it shows with the issue.

 VStack(alignment: .leading, spacing: 10) {
                Text("Connection Pin:")
                    .font(.headline)
                    .foregroundColor(.gray)
                
                Button {
                    print("Button tapped!")
                } label: {
                    Text("Tap me")
                        .font(.title)
                        .foregroundColor(Color.red)
                        .bold()
                }
                .background(Color.white)
}

enter image description here

enter image description here

2 Answers 2

0

Your code is just fine, I tested it and its showing how you want red text and white background, I am attaching an image on what I see in my simulator.enter image description here

Sign up to request clarification or add additional context in comments.

1 Comment

It show correctly on iOS but when I run the same code on macOS it does not look that way. On macOS its showing the white background over the Text. I clean build folder then rebuild but for some reason on macOS it keeps putting all of my button text behind the white background
0

Try using .buttonStyle(.plain)

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.