There's an issue in the iOS 17 beta where passing nil
to activityBackgroundTint(_:) does not use the system's default background material as expected. Instead, it's showing a solid black color instead of the correct tint that matches the rest of the system in iOS 16.
iOS 17 Beta Breaks activityBackgroundTint(_:) on Live Activities
What should I do? Six days ago, I submitted both feedback in Feedback Assistant as well as a Technical Support Incident (TSI), but I haven't received a reply to either.
Have you solved it? I have the same problem
Same here. Hope some one can solve this. 🙏
Same issue here on the release candidate
Same issue here on the release candidate. Blake, have you heard back on your TSI?
Just as a quick follow up, I was able to get transparency to match the system by doing
.activityBackgroundTint(.black.opacity(0.4))
However, it's still stuck in dark mode
Yeah I had to just default to dark mode too, which is a shame, but at least we have our transparency back
The Environment(\.colorScheme)
is broken. Always in dark mode.
.activityBackgroundTint(Color.clear)
work for me
iOS 17.1 beta 2/3 has actually made this problem worse.
@Environment(\.colorScheme) var colorScheme
Always returns light mode. Attempting to use
UIColor { traitCollection in
traitCollection == .light ? .white : .black
}
is again always white. Color(uiColor: UIColor.systemBackground)
is also always white. So everything adapts properly until you actually try to write code to modify it. I can't figure out anyway to make the background transparent without it getting stuck in light mode. .clear
as the color works in dark mode, but makes the text illegible in light mode.
any solution?
I also had problem making this work, even colorsScheme enviroment didn't work. Now I found out that it works but only of Live activity view is in separate variable.
If everything is defined right inside Widget it desn't seems to work:
struct MyLiveActivity: Widget {
var body: some WidgetConfiguration {
ActivityConfiguration(for: MyActivityAttributes.self) { context in
@Environment(\.isLuminanceReduced) var isLuminanceReduced
@Environment(\.colorScheme) var colorScheme
VStack {
Text("\(isLuminanceReduced) \(colorScheme)") // always default values (false, light)
}
.activityBackgroundTint(colorScheme == .dark ? Color.black : Color.white) // always white
} dynamicIsland: { context in
DynamicIsland {
When it is in separate view, enviroments are working as intended:
struct MyLiveActivity: Widget {
var body: some WidgetConfiguration {
ActivityConfiguration(for: MyActivityAttributes.self) { context in
MyActivityLiveView(context: context)
@Environment(\.isLuminanceReduced) var isLuminanceReduced
@Environment(\.colorScheme) var colorScheme
VStack {
Text("\(isLuminanceReduced) \(colorScheme)") // always default values (false, light)
}
.activityBackgroundTint(colorScheme == .dark ? Color.black : Color.white) // always white
} dynamicIsland: { context in
DynamicIsland {
struct MyActivityLiveView: View {
@Environment(\.isLuminanceReduced) var isLuminanceReduced
@Environment(\.colorScheme) var colorScheme
var context: ActivityViewContext<VirtualTableActivityAttributes>
var body: some View {
VStack {
Text("\(isLuminanceReduced) \(colorScheme)") // actual values (true, dark)
}
.activityBackgroundTint(colorScheme == .dark ? Color.black : Color.white) // colors are changeing, when changing from light to dark mode
}
}
.activityBackgroundTint(nil)
still unfortunately make it only white and black but now you can you can at least customise it.
This is closest I got to match notification background / ios 16 default:
.activityBackgroundTint(colorScheme == .dark ? Color(Color.systemBackground.resolve(in: environment)).opacity(0.43) : Color(Color.systemBackground.resolve(in: environment)).opacity(0.43))
Color.systemBackground
is just an UIColor:
extension Color {
// MARK: - Background Colors
static let systemBackground = Color(UIColor.systemBackground)
}
This Color extension is from this answer: https://stackoverflow.com/a/64414674
I still have the same problem
There is a walk around. Detect the colorScheme in side a View:
struct LiveActivity: View {
@Environment(\.colorScheme) var colorScheme
var body: some View {
someview {}
.backgroud(colorScheme == .light ? Color.white.opacity(0.43) : Color.black.opacity(0.43)
.activityBackgroundTint(Color.black.opacity(0))
}
}
and then call the view inside your Live Activity, it will automatically update based on color mode of your device