RoundedRectangularShape

A protocol of InsettableShape that describes a rounded rectangular shape.

ProtocoliOS 26.0+macOS 26.0+tvOS 26.0+watchOS 26.0+visionOS 26.0+RoundedRectangularShape in SwiftUI

Declaration

React
type RoundedRectangularShape =
  | Capsule
  | Circle
  | Rectangle
  | RoundedRectangle
  | UnevenRoundedRectangle;
Swift
protocol RoundedRectangularShape : InsettableShape

Overview

Conform your InsettableShape type to RoundedRectangularShape when your shape is a rounded rectangular with four corners and you want to expose information about the corners. For example, a custom triangle Shape is not fit for such conformance, while a custom rectangle Shape could benefit from providing the implementation, especially when the shape is used as a container shape in View.containerShape(_:)-(RoundedRectangularShape) to achieve concentricity.

System shapes like Rectangle, RoundedRectangle, UnevenRoundedRectangle, Capsule, and Circle already provide default implementation for this protocol.

From Apple’s SwiftUI documentation. Code samples there are Swift.

Used by

See also

More in Drawing and shapes.