Press "Enter" to skip to content

【SwiftUI】画像を円形に切り取る

clipShape モディファイアでViewを切り取ることができます。切り取ることができる形状は以下のとおりです。

形状
四角形Rectangle()
角丸の四角形RoundedRectangle()
カプセル形Capsule()
円形Circle()
楕円形Ellipse()
var body: some View {
    Image("Red")
        .resizable()
        .aspectRatio(contentMode: .fill)
        .frame(width: 50, height: 50, alignment: .center)
        .clipShape(Circle())
}

コメントを残す

メールアドレスが公開されることはありません。 が付いている欄は必須項目です