Skip to content

Commit 54f0f9a

Browse files
committed
Update OS 26.0
1 parent 2f5da26 commit 54f0f9a

2 files changed

Lines changed: 30 additions & 18 deletions

File tree

Demo/Demo/Samples/_BlankTemplate.swift

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,19 @@ import SwiftGlass
1010

1111
struct BlankTemplate: View {
1212
var body: some View {
13-
VStack {
14-
Text("Hello, Developer!")
13+
ZStack {
14+
bg
15+
Text("Hello, Developer!")
16+
.bold()
1517
.padding(25)
1618
.glass()
1719
}
1820
}
21+
22+
var bg: some View {
23+
LinearGradient(colors: [Color.clear, Color.pink.opacity(0.85)], startPoint: .topLeading, endPoint: .bottomTrailing)
24+
.ignoresSafeArea()
25+
}
1926
}
2027

2128
#Preview("Dark") {

Sources/SwiftGlass/GlassBackgroundModifier.swift

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -70,23 +70,28 @@ public struct GlassBackgroundModifier: ViewModifier {
7070
/// 2. Gradient stroke for edge highlighting
7171
/// 3. Shadow for depth perception
7272
public func body(content: Content) -> some View {
73-
content
74-
.background(material) // Use the specified material for the frosted glass base
75-
.cornerRadius(radius) // Rounds the corners
76-
.overlay(
77-
// Adds subtle gradient border for dimensional effect
78-
RoundedRectangle(cornerRadius: radius)
79-
.stroke(
80-
LinearGradient(
81-
gradient: Gradient(colors: gradientColors()),
82-
startPoint: .topLeading,
83-
endPoint: .bottomTrailing
84-
),
85-
lineWidth: strokeWidth
86-
)
87-
)
73+
if #available(iOS 26.0, macOS 26.0, watchOS 26.0, tvOS 26.0, visionOS 26.0, *) {
74+
content
75+
.glassEffect()
76+
} else {
77+
content
78+
.background(material) // Use the specified material for the frosted glass base
79+
.cornerRadius(radius) // Rounds the corners
80+
.overlay(
81+
// Adds subtle gradient border for dimensional effect
82+
RoundedRectangle(cornerRadius: radius)
83+
.stroke(
84+
LinearGradient(
85+
gradient: Gradient(colors: gradientColors()),
86+
startPoint: .topLeading,
87+
endPoint: .bottomTrailing
88+
),
89+
lineWidth: strokeWidth
90+
)
91+
)
8892
// Adds shadow for depth and elevation
89-
.shadow(color: shadowColor.opacity(shadowOpacity), radius: shadowRadius, x: shadowX, y: shadowY)
93+
.shadow(color: shadowColor.opacity(shadowOpacity), radius: shadowRadius, x: shadowX, y: shadowY)
94+
}
9095
}
9196

9297
/// Generates the gradient colors based on the selected style

0 commit comments

Comments
 (0)