Quantcast
Channel: Recent Questions - Stack Overflow
Viewing all articles
Browse latest Browse all 16420

Background colour of Picker control in SwiftUI

$
0
0

I have a picker control (SwiftUI) and I am having trouble setting the background colour correctly.

In the below, I have set the background as GREEN, but notice there is a slightly darker overlayed colour around the text itself.

See the word "One" below. There is a dark overlay over the text component of the picker control.

This behaviour is only seen on a physical iPhone, but it is not shown on the simulator.

enter image description here

Complete code of example is below.

The effect I am trying to achieve is like that shown on the simulator, where the background green colour of the picker control is exactly the same as the background green colour of the Text view above it.

Is it achievable to have a picker control WITHOUT having this darker overlay colour around the text portion of the control?

import SwiftUIstruct Test: View {    var items = ["One", "Two", "Three", "Four"]    @State private var selection = "One"    var body: some View {        VStack {            Text("Text")                .foregroundStyle(.white)                .frame(width: 150, height: 35)                .background(.green)            Picker("Please choose an item", selection: $selection) {                ForEach(items, id: \.self) {                    Text($0)                }            }            .frame(width: 150, height: 35)            .background(.green)            .tint(.white)            Text("You selected: \(selection)")            Spacer()        }        .padding(.top,50)    }}#Preview {    Test()}

Viewing all articles
Browse latest Browse all 16420

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>