I know I can change the views background colors in SwiftUI with this code:
.background(Color(.systemGroupedBackground))
But I can't do it for widget background color itself!
I use this code:
struct XWidget: Widget { // MARK: Widget is defined here
var body: some WidgetConfiguration {
StaticConfiguration(
kind: "xWidget",
provider: xProvider(),
placeholder: Text("Loading...")) { entry in
xWidgetEntryView(entry: entry).background(Color(.systemGroupedBackground)) // <= here
}.supportedFamilies([.systemSmall, .systemMedium, .systemLarge])
}
}
But the result is like this:
Colour and transparecy options are available in Widget Settings. If you want bright font color and dark widget background, you can check the box for «Dark background color».
Not only can you change app icons with shortcuts of your own, customize app icons even more, and place widgets on the home screen, but iOS 14 also allows you to create custom widgets and welcomes support for third-party widgets for users to try out.
Instead of having a plain widget, You can also set the background of a widget using any photo of your choice from your iPhone/iPad. The information on the widget will display over the background image. Now, that we are done with customizing our widget color, theme, and background, let’s set the widget on the home screen of our iPhone and iPad.
Start by downloading/installing the Color Widgets app from the App Store You will see a lot of color options and styling for widgets Next, you can also tweak the font style and background as per your choice. To create a custom font and themeing use the Edit Widget option.
While Apple has finally welcomed the idea of widgets on iOS, there’s still a lot of work that needs to be done to make them more useful or at least more aesthetic to be looked at. In order to create a customized widget for your home screen on iOS 14, you need to download and install third-party apps on your iPhone.
For those who are trying to change the widget background that supports both dark and light modes.
Assets.xcassets
in your Widget Extension
"WidgetBackground"
"WidgetBackground"
"Any, Dark"
.background(Color("WidgetBackground"))
public var body: some WidgetConfiguration {
StaticConfiguration(kind: kind, provider: MyCustomTimeline()) { entry in
MyCustomWidgetView(entry: entry)
.background(Color("WidgetBackground"))
}
}
You need to specify full frame, as on below demo
StaticConfiguration(
kind: "xWidget",
provider: xProvider(),
placeholder: Text("Loading...")) { entry in
xWidgetEntryView(entry: entry)
.frame(maxWidth: .infinity, maxHeight: .infinity) // << here !!
.background(Color.green)
}.supportedFamilies([.systemSmall, .systemMedium, .systemLarge])
backup
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With