Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

404
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!