Instance Method インスタンスメソッド

cornerRadius(_:antialiased:)

Clips this view to its bounding frame, with the specified corner radius. このビューをそれの境界枠へと切り抜きます、この指定された角丸めで。

Declaration 宣言

func cornerRadius(_ radius: CGFloat, antialiased: Bool = true) -> some View

Return Value 戻り値

A view that clips this view to its bounding frame with the specified corner radius. あるビュー、それはこのビューをそれの境界枠へとこの指定された角丸めで切り抜きます。

Parameters パラメータ

antialiased

A Boolean value that indicates whether the rendering system applies smoothing to the edges of the clipping rectangle. あるブール値、それは滑らかさが切り抜き矩形の縁に適用されるかどうかを指し示します。

Discussion 議論

By default, a view’s bounding frame only affects its layout, so any content that extends beyond the edges of the frame remains visible. Use cornerRadius(_:antialiased:) to hide any content that extends beyond these edges while applying a corner radius. 初期状態では、ビューのもつ境界枠はそれのレイアウトに影響するだけです、それでその枠の縁を越えて広がるあらゆる内容は、可視のままです。cornerRadius(_:antialiased:)を使って、それら縁を越えるどんな内容も隠して、それと同時に角丸めを適用してください。

The following code applies a corner radius of 25 to a text view: 以下のコードは、25の角丸めをテキストビューに適用します:


Text("Rounded Corners")
    .frame(width: 175, height: 75)
    .foregroundColor(Color.white)
    .background(Color.black)
    .cornerRadius(25)

A screenshot of a rectangle with rounded corners bounding a text

See Also 参照

Masks and Clipping