Okay, so in the meantime you could use something like this:
public struct Conditional<Content> {
public let content: Content
public init(_ content: Content) {
self.content = content
}
}
extension View {
var conditional: Conditional<Self> { Conditional(self) }
}
@ViewBuilder func showAccessory(_ enabled: Bool, accessoryContent: View) -> some View {
if(enabled) {
if #available(iOS 26.2, *) {
content
.tabViewBottomAccessory(isEnabled: enabled) {
accessoryContent
}
} else {
if #available(iOS 26.0, *) {
content
.tabViewBottomAccessory() {
accessoryContent
}
} else {
content
}
}
} else {
content
}
}
// Use it like this:
...
MyView {
}
.conditional.showAccessory(true /*or false*/, accessoryContent: MyAccessoryView())
Caveat: I have not tried this.
Topic:
UI Frameworks
SubTopic:
SwiftUI
Tags: