Post

Replies

Boosts

Views

Activity

SwiftUI - View within Sheet Displayed Incorrectly in iOS 17
In iOS 17, when I try to display a form inside a sheet, under certain conditions the section title and button label will have incorrect style. Here's a minimal code that can reproduce the issue. The platform is iOS 17.0 (21A5303d) import SwiftUI struct TestView: View { var body: some View { List { RowView() } } } struct RowView: View { @State var showSheet = false var body: some View { VStack { Button("Show Sheet") { showSheet = true } .sheet(isPresented: $showSheet) { MySheet() } } } } struct MySheet: View { var body: some View { Form { Section { Text("Hello World!") Button { // nothing } label: { Label("Button", systemImage: "star") } } header: { Label("Section", systemImage: "star") } } } } #Preview { TestView() } When I tap the button Show Sheet, the sheet pops out as shown in the screenshot below: There are 2 incorrect behavior found in this screenshot: The section title should have a smaller font size and in gray color. The button label's icon shouldn't be dimmed out. For comparison, the correct result should look like the following screenshot:
2
0
756
Sep ’23
SwiftUI - scrollTo Animation Disappears
In the following code snippet, I use proxy.scrollTo() to scroll to a target. In order to animate the scrolling process, I wrapped this function call inside withAnimation. This code works on iOS 16, but on iOS 17, it scroll without any animation. Is this a bug or is there an API change? Thanks! import SwiftUI struct ScrollTest: View { var body: some View { ScrollViewReader { proxy in List { Button("Begin Scroll") { withAnimation { proxy.scrollTo(15, anchor: .top) } } ForEach(1..<50) { i in Text("Item \(i)") .id(i) } } } } }
4
1
1.6k
Aug ’23