SwiftUIでVStackの周りに影をつける
SwiftでUIViewの周りに影をつける方法です。
ImageのViewの周りに影をつけています。
shadowOffset
で影の位置を移動させることができ、サンプルコードでは影を右下に移動させています。
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 ContentView: View { | |
var body: some View { | |
VStack { | |
Image("icon") | |
.resizable() | |
.frame(width: 150, height: 150) | |
Text("Snorlax") | |
} | |
.padding() | |
.background(Color.white) | |
.border(Color.black, width: 2) | |
.clipped() | |
.shadow(color: Color.gray.opacity(0.6), radius: 4, x: 10, y: 10) | |
} | |
} |