image not appearing in SwiftUI

Viewed 4628

Hello I am new in SwiftUI, I am working with the tag Image("my image"), my image is on the directory Assets.xcassets everything okay when I am editing but when I am testing with my cell or my simulator in my mac the image not appear and I don´t understand why my code is so simple , and if can tell me who show the complete screen beacuse if I am using some Text or TextField in my screen not appear all the screen and I dont know how move the screen to down. really thanyou for help me.

I am Using iOS 13.4 whit a iPhone 7

image

var body: some View {
        VStack {
            ZStack{
            Image("icon-logo")
               .resizable()
                .scaledToFit()
                .clipShape(Circle())
                .overlay(Circle().stroke(Color(red: 39 / 255, green: 113 / 255, blue: 233 / 255), lineWidth: 5))
                .shadow(radius: 20)
                
            }
            Text("Datos de Usuario")
            VStack{
                Text("Nombre")
                 .offset(x: -140, y: 0)
            TextField("--Nombre--", text: /*@START_MENU_TOKEN@*//*@PLACEHOLDER=Value@*/.constant("")/*@END_MENU_TOKEN@*/)
                .offset(x: 20, y: 0)
                .padding(15)
                .background(Color(red: 242 / 255, green: 242 / 255, blue: 242 / 255))
                Text("Apellido")
                     .offset(x: -140, y: 0)
                TextField("--Apellido--", text: /*@START_MENU_TOKEN@*//*@PLACEHOLDER=Value@*/.constant("")/*@END_MENU_TOKEN@*/)
                    .offset(x: 20, y: 0)
                    .padding(15)
                    .background(Color(red: 242 / 255, green: 242 / 255, blue: 242 / 255))

    }
}

struct TercerIUView_Previews: PreviewProvider {
    static var previews: some View {
        TercerIUView()
    }
}
3 Answers

It is not clear where do you use that code, but try to add rendering mode explicitly,

Image("icon-logo")
   .renderingMode(.original)  // << here !!
   .resizable()

The reason why the image might not be showing is because the name is not matching the name of the asset in the catalog.

I would suggest that you double check the name of the image in Assets.xcassets and make sure that is icon-logo

This is how it should look:

Assets

As for the second question, it looks like the keyboard is covering the textfields, the has been solved here: Move TextField up when the keyboard has appeared in SwiftUI

I think is because my Iphone 7 in the symulator and physical is old for swiftUI, I was running the symulator with iphone 11 and the image appear very well is a shame for me only I have my old iphone 7 to run my apps

Related