I try to replace the default menu bar item. but this code still shows two button items.
import SwiftUI
@available(watchOS 10.0, *)
struct TabViewPreview<Content: View>: View {
let content: Content
init(@ViewBuilder content: () -> Content) {
self.content = content()
}
@State private var selection: String? = "preview"
var body: some View {
NavigationSplitView {
List(selection: $selection) {
Text("preview").tag("preview")
}
} detail: {
TabView {
content
}
.toolbar(content: {
ToolbarItem(placement: .topBarLeading) {
Button(action: {}) {
Image(systemName: "shared.with.you")
}
}
})
.tabViewStyle(.verticalPage)
}
}
}
@available(watchOS 10.0, *)
#Preview {
TabViewPreview {
Text("A")
}
}