Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

406
Vistas
iOS widget background-image goes black after couple of minutes

I am currently developing an iOS widget with SwiftUI and have a strange behaviour of the background-image of my medium-sized widget.

I am setting a background-image depending on the current color mode of the device, which works most of the time. But when the app is in the background for a couple of minutes, the background-image goes black, which makes the text unreadable. Any other UI-elements are still visible. When I resume to my app, the widget refreshes itself and the background-image is visible again.

The background-images are included in my image.assets of my widget-extension, so it should be always accessible for the widget, shouldn’t it?

This widget is available for iOS 14 and above.

This is how I set the background-image:

    struct MediumWidget: View {
           @Environment(\.colorScheme) var colorScheme
    
           var body: some View {
               HStack(alignment: .center, spacing: nil) {
                  // Content (shortend)
               }
               .frame(maxWidth: .infinity, maxHeight: .infinity)
               .edgesIgnoringSafeArea(.all)
               .background(
                    backgroundImage
                    .renderingMode(.original)
                    .resizable()
                    .scaledToFill()
               )
           }
        var backgroundImage: Image {
            if colorScheme == .dark {
                return Image("dark")
            }
            return Image("light")
            
        }
    }

I am clueless of what to do, does someone know what I am doing wrong?

Thank you in advance!

EDIT 1: This problem only occurs with these two background-images. When I use any other background-image, the widget does not go black.

over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

Since the problem only occurs with these two specific images it seems like the files are either

  1. Not correctly added to the assets folder
  2. Broken or corrupt

Try to generate a completely new file for both pictures (e.g. take screenshots) and replace them with the current images in the assets folder. That should most likely fix your issue.

over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda