Created
May 6, 2022 08:22
-
-
Save jayesh15111988/fa873576175564aae47eb569831b7e2d to your computer and use it in GitHub Desktop.
Adding Shadow View in SwiftUI
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import SwiftUI | |
struct ShadowView: View { | |
let xOffset: CGFloat | |
let yOffset: CGFloat | |
var body: some View { | |
Text("SwiftUI is Awesome").padding().background( | |
Rectangle() | |
.fill(Color.white) | |
.cornerRadius(12) | |
.shadow( | |
color: Color.gray.opacity(0.7), | |
radius: 8, | |
x: xOffset, | |
y: yOffset | |
) | |
) | |
} | |
} | |
struct ShadowView_Previews: PreviewProvider { | |
static var previews: some View { | |
VStack(spacing: 16) { | |
ShadowView(xOffset: 0, yOffset: 0) | |
ShadowView(xOffset: -8, yOffset: 0) | |
ShadowView(xOffset: 8, yOffset: 0) | |
ShadowView(xOffset: 0, yOffset: -8) | |
ShadowView(xOffset: 0, yOffset: 8) | |
ShadowView(xOffset: -8, yOffset: -8) | |
ShadowView(xOffset: 8, yOffset: -8) | |
ShadowView(xOffset: -8, yOffset: 8) | |
ShadowView(xOffset: 8, yOffset: 8) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment