I'm now working on putting segmented style picker inside NavigationBarItems. Here's the code I'm using:
struct ContentView: View {
let modes = ["temperature", "distance"]
var body: some View {
NavigationView {
ZStack {
...
}
}
.navigationBarItems (leading:
Picker ("Select mode:", selection: $currentMode) {
ForEach (0..<mods.count) {
Text(self.mods[$0])
}
}
.pickerStyle(SegmentedPickerStyle())
)
}
}
}
If I use leading:
the picker is shown on the left, if I use trailing:
then the picker is shown on the right. How can I put it in the centre ?
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.