0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

【SwiftUI】角丸をつくるとき

0
Last updated at Posted at 2026-06-19

image.png

このような感じの角丸のラベルを作成するとき。

.cornerRadius(xx)をつけていませんか?

Radiusってどのくらいで角丸になるんだっけ…とするよりも、
.clipShape(Capsule())で解決できます。

Text("あいうえお")
    .font(.caption)
    .foregroundColor(.white)
    .padding(.horizontal, 16)
    .padding(.vertical, 8)
    .background(.green)
    .clipShape(Capsule())

以上です。

  • Xcode26.2
  • Swift 6.2.3
0
1
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
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?