Ios Xcode模拟器未显示swift ui占位符文本

Ios Xcode模拟器未显示swift ui占位符文本,ios,swift,Ios,Swift,我的文本字段中有占位符文本,在swift UI的预览屏幕上显示,但是带有Xcode的模拟器不显示占位符文本。 它可以在预览中工作,但不能在Xcode模拟器中工作,所以它只是swift UI或我的代码中的一个bug吗 下图 由于暗模式,占位符在您定义的颜色的文本字段背景上不可见。 解决办法可以是: 在Assets.xcsets中定义新颜色,从inspector的右侧将外观更改为Any,深色,并将颜色更改为您喜欢的颜色。然后,您可以在文本字段中将其用作背景 您使用的是什么版本的xcode?对我来说

我的文本字段中有占位符文本,在swift UI的预览屏幕上显示,但是带有Xcode的模拟器不显示占位符文本。

它可以在预览中工作,但不能在Xcode模拟器中工作,所以它只是swift UI或我的代码中的一个bug吗

下图


由于暗模式,占位符在您定义的颜色的文本字段背景上不可见。 解决办法可以是:

Assets.xcsets
中定义新颜色,从inspector的右侧将外观更改为
Any,深色
,并将颜色更改为您喜欢的颜色。然后,您可以在文本字段中将其用作背景


您使用的是什么版本的
xcode
?对我来说没问题。@Mac3n Xcode 11.3.1版我使用了相同的版本,但对我来说没问题,并且在屏幕上显示了占位符simulator@Mac3n可能是因为模拟器处于黑暗模式吗?是的!这是因为黑暗模式,在黑暗模式下,苹果会改变你背景中看不到的占位符颜色。您也应该为暗模式定义一个新的背景色
import SwiftUI

struct doctor: View {
@State var userInputone: String = ""
@State var userInputtwo: String = ""
@State var userInputthree: String = ""
@State var userInputfour: String = ""
@State var userInputfive: String = ""
@State var userInputsix: String = ""

var body: some View {
    ZStack{
        Color.white
    .edgesIgnoringSafeArea(.all)
        VStack{
            Text("Whats up Doc?")
                .font(.largeTitle)
                .foregroundColor(Color.gray)
                .multilineTextAlignment(.leading)



            Text("Let's get to know each other")
                .foregroundColor(Color.gray)
                .multilineTextAlignment(.leading)

                 .padding()

            .shadow(radius:10)
            TextField("FirstName", text: $userInputone)
            .padding()
             .background(Color(red: 0.937, green: 0.952, blue: 0.956))
            .cornerRadius(15)
                .padding()

            .shadow(radius:10)
            TextField("LastName", text: $userInputtwo)
                .padding()
                .background(Color(red: 0.937, green: 0.952, blue: 0.956))
                 .cornerRadius(15)
                .padding()
               .shadow(radius:10)


            TextField("LastName", text: $userInputthree)
                .padding()
              .background(Color(red: 0.937, green: 0.952, blue: 0.956))
                  .cornerRadius(15)
                   .padding()
        .shadow(radius:10)
            TextField("LastName", text: $userInputfour)
                    .padding()
                   .background(Color(red: 0.937, green: 0.952, blue: 0.956))
                   .cornerRadius(15)
                                  .padding()
            .shadow(radius:10)
            TextField("LastName", text: $userInputfive)
                 .padding()
                .background(Color(red: 0.937, green: 0.952, blue: 0.956))
               .cornerRadius(15)
               .padding()
            .shadow(radius:10)
            TextField("LastName", text: $userInputsix)
              .padding()
              .background(Color(red: 0.937, green: 0.952, blue: 0.956))
               .cornerRadius(15)
               .padding()
           .shadow(radius:10)

            NavigationLink(destination: createaccount()){

               Text("Next")
             .fontWeight(.bold)
            .foregroundColor(Color.white)
              .padding(.all, 20.0)
              .frame(height: 44.0)
            .frame(width: 300.0)
        .background(LinearGradient(gradient: Gradient(colors: [Color.gray, Color.purple]), startPoint: .top, endPoint: .bottom))
          .cornerRadius(20)


        }
        }


    }




}
}

struct doctor_Previews: PreviewProvider {
static var previews: some View {
    doctor()
}
}