10

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()
    }
}

4 Answers4

8

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

Image("icon-logo")
   .renderingMode(.original)  // << here !!
   .resizable()
Asperi
  • 228,894
  • 20
  • 464
  • 690
  • Just I have a view and I am using Image like to view in my iphone 7 with iOS 13.5 but the image not appear when I choose iphone 11 the image appear but when I choose iphone 7 not appear the image I think is by the software exist other form to put the image? – JuanCarlos-Colin Jun 23 '20 at 04:12
  • You rule for this.. worked to fix my iOS13 woes and the image not loading correctly. Note that you can also change this option directly in the Asset catalog. Theres a drop down for Rendering Mode. – shokaveli Mar 18 '21 at 19:47
1

Don't forget to insert images in the Assets of the App!

Vyacheslav
  • 26,359
  • 19
  • 112
  • 194
0

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

egmoll7
  • 119
  • 3
0

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