Last active
April 23, 2024 21:05
-
-
Save benigumocom/9a73f3a700eb6a056c83d147cdcaa0c4 to your computer and use it in GitHub Desktop.
【SwiftUI】shadow() with compositingGroup() 👉 https://android.benigumo.com/20240424/shadow-effect/
This file contains hidden or 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 TestShadow: View { | |
var body: some View { | |
VStack { | |
Text("こちらへ") | |
Text("▶") | |
} | |
.padding() | |
.background(.yellow) | |
// .contentShape(.rect) // NG | |
// .clipShape(.rect) // OK | |
// .clipped() // OK | |
.compositingGroup() // OK | |
.shadow(color: .secondary, radius: 2, x: 5, y: 5) // * | |
// .opacity(0.5) // always | |
// .foregroundStyle(.red) // always | |
// .scaleEffect(2) // always | |
} | |
} | |
#Preview("TestShadow") { | |
TestShadow() | |
} |
Author
benigumocom
commented
Apr 23, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment