Skip to content

Instantly share code, notes, and snippets.

@benigumocom
Last active April 23, 2024 21:05
Show Gist options
  • Save benigumocom/9a73f3a700eb6a056c83d147cdcaa0c4 to your computer and use it in GitHub Desktop.
Save benigumocom/9a73f3a700eb6a056c83d147cdcaa0c4 to your computer and use it in GitHub Desktop.
【SwiftUI】shadow() with compositingGroup() 👉 https://android.benigumo.com/20240424/shadow-effect/
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()
}
@benigumocom
Copy link
Author

sc 2024-04-24 at 5 35 26
sc 2024-04-24 at 5 43 13

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment