-
Notifications
You must be signed in to change notification settings - Fork 16
/
GlassmorphismView.swift
51 lines (44 loc) · 1.23 KB
/
GlassmorphismView.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
//
// ContentView.swift
// Glassmorphism
//
// Created by Ganesh on 18/08/23.
//
import SwiftUI
struct GlassmorphicStyle:ButtonStyle{
func makeBody(configuration: Configuration) -> some View {
configuration.label
.foregroundColor(.white)
.background(.ultraThinMaterial.opacity(0.7),in:RoundedRectangle(cornerRadius: 10))
.overlay(.white.opacity(0.5),in:RoundedRectangle(cornerRadius: 10).stroke(style: .init()))
}
}
extension ButtonStyle where Self == GlassmorphicStyle {
static var glassmorphism: GlassmorphicStyle {
.init()
}
}
struct GlassmorphismView: View {
var body: some View {
ZStack(alignment: .center){
Image("apple")
.resizable()
.scaledToFill()
.ignoresSafeArea()
Button {
print("hello")
} label: {
Text("")
.frame(maxWidth: .infinity)
.frame(height: 200)
}
.padding(.horizontal,40)
.buttonStyle(.glassmorphism)
}
}
}
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
GlassmorphismView()
}
}