Created
February 20, 2026 03:01
-
-
Save samhenrigold/c568bf21948c4eea69f4989417289f6e to your computer and use it in GitHub Desktop.
SwiftUI segmented control rendering bug
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // | |
| // ContentView.swift | |
| // toolbar-picker-bug | |
| // | |
| // Created by Sam on 2026-02-19. | |
| // | |
| import SwiftUI | |
| struct ContentView: View { | |
| @State private var tabSelection: Int = 0 | |
| let colors: [Color] = [.indigo, .white, .black, .gray] | |
| var body: some View { | |
| NavigationStack { | |
| ScrollView { | |
| ForEach(colors, id: \.self) { color in | |
| color | |
| .containerRelativeFrame(.vertical) | |
| } | |
| } | |
| .toolbar { | |
| ToolbarItem { | |
| Picker("Tab", selection: $tabSelection) { | |
| Label("First", systemImage: "square.and.arrow.up") | |
| .tag(0) | |
| Label("Second", systemImage: "folder") | |
| .tag(1) | |
| } | |
| .pickerStyle(.segmented) | |
| } | |
| .sharedBackgroundVisibility(.hidden) | |
| } | |
| } | |
| } | |
| } | |
| #Preview { | |
| ContentView() | |
| } |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
CleanShot.2026-02-19.at.21.53.10.mp4
CleanShot.2026-02-19.at.21.36.48.mp4