どうも、ちょげ(@chogetarou)です。
RoundedRectangleの背景色を設定する方法を紹介します。
方法

RoundedRectangleの背景色を設定するには、background修飾子を使います。
まず、RoundedRectangleにbackground修飾子を付与します。
そして、background修飾子の引数に色を指定します。
RoundedRectangle()
.background(color)
background(背景色)を付与することで、RoundedRectangleの背景色を設定できます。
使用例

struct ContentView: View {
var body: some View {
VStack {
RoundedRectangle(cornerRadius: 10)
.stroke(Color.blue, lineWidth: 4)
.frame(width: 200, height: 200)
.background(Color.green.cornerRadius(10))
}
}
}
コメント