どうも、ちょげ(@chogetarou)です。
Buttonの形を変える方法を紹介します。
方法

Buttonの形を変えるには、clipShape修飾子を使います。
まず、ButtonにclipShape修飾子を付与します。
そして、clipShape修飾子の引数にButtonの形を指定します。
Button(・・・)
.clipShape(Shape())
clipShape修飾子の引数に指定した形が、Buttonの形になります。
使用例

struct ContentView: View {
var body: some View {
VStack {
Button("Button") {
print("Tap")
}
.padding()
.foregroundColor(.white)
.background(.blue)
.clipShape(Capsule())
}
}
}
コメント