@@ -76,45 +76,47 @@ public struct GlassBackgroundModifier: ViewModifier {
7676 /// 2. Gradient stroke for edge highlighting
7777 /// 3. Shadow for depth perception
7878 public func body( content: Content ) -> some View {
79+ // Check isInToolbar and iOS version first
80+ if isInToolbar {
81+ // Check if we're on iOS 26+
82+ if #available( iOS 26 . 0 , macOS 26 . 0 , watchOS 26 . 0 , tvOS 26 . 0 , visionOS 26 . 0 , * ) {
83+ // On iOS 26+, return content with tint only (no glass effect, no border)
84+ return AnyView ( content. tint ( color) )
85+ }
86+ // On iOS 18 and below, still apply glass effect when in toolbar
87+ return AnyView ( fallbackGlassEffect ( content: content) )
88+ }
89+
90+ // Not in toolbar - apply glass effect based on iOS version
7991 #if swift(>=6.0) && canImport(SwiftUI, _version: 6.0)
80- // Use new glass effect APIs available in newer Xcode/Swift versions
8192 if #available( iOS 26 . 0 , macOS 26 . 0 , watchOS 26 . 0 , tvOS 26 . 0 , visionOS 26 . 0 , * ) {
82- // Check if content is in a toolbar context
83- if isInToolbar {
84- AnyView (
85- content
86- . tint ( color)
87- )
88- } else {
89- AnyView (
90- content
91- #if !os(visionOS)
92- . glassEffect ( . regular. tint ( color. opacity ( colorOpacity) ) . interactive ( ) , in: . rect( cornerRadius: radius) )
93- #else
94- . background ( color. opacity ( colorOpacity) )
95- . background ( material)
96- . cornerRadius ( radius)
97- . overlay (
98- RoundedRectangle ( cornerRadius: radius)
99- . stroke (
100- LinearGradient (
101- gradient: Gradient ( colors: gradientColors ( ) ) ,
102- startPoint: . topLeading,
103- endPoint: . bottomTrailing
104- ) ,
105- lineWidth: strokeWidth
106- )
107- )
108- #endif
109- . shadow ( color: shadowColor. opacity ( shadowOpacity) , radius: shadowRadius, x: shadowX, y: shadowY)
110- )
111- }
93+ return AnyView (
94+ content
95+ #if !os(visionOS)
96+ . glassEffect ( . regular. tint ( color. opacity ( colorOpacity) ) . interactive ( ) , in: . rect( cornerRadius: radius) )
97+ #else
98+ . background ( color. opacity ( colorOpacity) )
99+ . background ( material)
100+ . cornerRadius ( radius)
101+ . overlay (
102+ RoundedRectangle ( cornerRadius: radius)
103+ . stroke (
104+ LinearGradient (
105+ gradient: Gradient ( colors: gradientColors ( ) ) ,
106+ startPoint: . topLeading,
107+ endPoint: . bottomTrailing
108+ ) ,
109+ lineWidth: strokeWidth
110+ )
111+ )
112+ #endif
113+ . shadow ( color: shadowColor. opacity ( shadowOpacity) , radius: shadowRadius, x: shadowX, y: shadowY)
114+ )
112115 } else {
113- AnyView ( fallbackGlassEffect ( content: content) )
116+ return AnyView ( fallbackGlassEffect ( content: content) )
114117 }
115118 #else
116- // Fallback for older Xcode versions (16.4 and earlier)
117- AnyView ( fallbackGlassEffect ( content: content) )
119+ return AnyView ( fallbackGlassEffect ( content: content) )
118120 #endif
119121 }
120122
0 commit comments