-
Notifications
You must be signed in to change notification settings - Fork 16
/
InsideShadowView.swift
45 lines (40 loc) · 1.25 KB
/
InsideShadowView.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
//
// ContentView.swift
// InsideShadow
//
// Created by Ganesh on 21/06/23.
//
import SwiftUI
struct InsideShadowView: View {
private let baseColor:Color = .init(red: 232/255, green: 232/255, blue: 232/255)
private let shadowColor:Color = .init(red: 197/255, green: 197/255, blue: 197/255)
@State private var shadowStyle:ShadowStyle = .inner(radius: 8)
@State private var selectedStyle:Int = 0
var body: some View {
VStack{
Picker("Shadow", selection: $selectedStyle) {
Text("Inner").tag(0)
Text("Drop").tag(1)
}
.pickerStyle(.segmented)
.onChange(of: selectedStyle, perform: { value in
updateStyle()
})
.padding(.vertical,50)
RoundedRectangle(cornerRadius: 20)
.fill(baseColor.gradient.shadow(shadowStyle))
.frame(width: 300,height: 300)
}
.padding()
}
private func updateStyle(){
switch selectedStyle{
case 0:
shadowStyle = .inner(color: shadowColor,radius: 8 , x: 20,y: 20)
case 1:
shadowStyle = .drop(color:shadowColor,radius: 8,x: 20,y: 20)
default:
break
}
}
}