Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

408
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda