Post

Replies

Boosts

Views

Activity

TabView with ScrollView: scroll position ID not updating when tapping Tab item
When working with SwiftUI TabView and ScrollView at root level with scrollPosition(id:anchor:), after tapping on Tab item the ScrollView scrolls to the top, but the scroll position ID does not get updated. struct ContentView: View { @State var positionID: Int? var body: some View { TabView { Tab("Test", systemImage: "house") { ScrollView(.vertical) { LazyVStack(pinnedViews: [.sectionHeaders]) { ForEach(0 ... 100, id: \.self) { index in Text("\(index)") } } .scrollTargetLayout() } .scrollPosition(id: $positionID, anchor: .top) .onChange(of: positionID) { _, newValue in print(newValue) } } } } } FB15964820
0
0
141
2w
containerBackgroundRemovable(false) breaks tinting for the whole widget
I've encountered what appears to be a bug with widget background image tinting in SwiftUI. When using an image in containerBackground(for: .widget) to fill the entire widget, adding the .containerBackgroundRemovable(false) modifier breaks the widget's tinting behavior: The background image becomes permanently tinted, ignoring any widgetAccentedRenderingMode(_ renderingMode: WidgetAccentedRenderingMode?) settings Text elements become tinted even with .widgetAccentable(false) applied Sample code: struct MyWidget: Widget { var body: some WidgetConfiguration { AppIntentConfiguration(kind: "MyWidget", intent: MyWidgetIntent.self, provider: Provider()) { entry in MyWidgetView(entry: entry) .containerBackground(for: .widget) { Image("background") .resizable() .widgetAccentedRenderingMode(.fullColor) .scaledToFill() } } .containerBackgroundRemovable(false) // This causes the issue } } Workaround: I've managed to resolve this by using a ZStack with disabled content margins and passing the widget size through the entry. However, this seems like unintended behavior with the .containerBackgroundRemovable(false) modifier. Has anyone else encountered this issue or found a better solution? Device: iPhone 15 Pro iOS Version: 18.1 Xcode Version: 16.1
0
0
172
Nov ’24