4
5

【SwiftUI】特定の角だけ丸角にする(iOS16)

Posted at

はじめに

iOS15以下を対応する場合は以下の記事の方法が良さそうです。

完成サンプル

Simulator Screenshot - iPhone 15 - 2023-11-25 at 12.58.35.png

実装

import SwiftUI

struct ContentView: View {
    var body: some View {
        Image(.sample)
            .resizable()
            .scaledToFit()
+           .clipShape(.rect(
+               topLeadingRadius: 0,
+               bottomLeadingRadius: 50,
+               bottomTrailingRadius: 0,
+               topTrailingRadius: 50
+           ))
            .padding(20)
    }
}

おわり

iOS16からめっちゃ簡単に書けるようになりましたね

公式ドキュメント

4
5
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
5