enum SectionType: String, CaseIterable {
case top = "Top"
case best = "Best"
}
struct ContentView : View {
@State private var selection: Int = 0
var body: some View {
SegmentedControl(selection: $selection) {
ForEach(SectionType.allCases.identified(by: \.self)) { type in
Text(type.rawValue).tag(type)
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
How do I run code (e.g print("Selection changed to \(selection)") when the $selection state changes? I looked through the docs and I couldn't find anything.
我正在将约500行数据加载到中List。当我有10行时还可以,但是现在我有500行,这非常慢。有什么我可以做的来改善它的性能吗?
List {
SegmentedControl(selection: $feedType) {
ForEach(FeedType.allCases.identified(by: \.self)) { type in
Text(type.rawValue)
}
}
ForEach(store.stories) { story in
NavigationButton(destination: Text("")) {
StoryRow(story: story)
}
}
}
Run Code Online (Sandbox Code Playgroud) I'm trying to create an input similar like this (?) with SwiftUI.
I've made progress but I can't figure out how to change the height of the text fields and make the input text size bigger.
我正在尝试SFSafariViewController从a 呈现一个,NavigationButton但是我不确定如何使用SwiftUI。
在UIKit中,我只会做:
let vc = SFSafariViewController(url: URL(string: "https://google.com"), entersReaderIfAvailable: true)
vc.delegate = self
present(vc, animated: true)
Run Code Online (Sandbox Code Playgroud)