Circle

Published Oct 21, 2022
Contribute to Docs

SwiftUI includes various pre-built shapes, like rectangles, circles, and capsules which can be generated, coloured, and positioned as desired.

Syntax

Circle()
// Modifiers

Circle is one of the pre-built shapes. A developer can add modifiers to use different properties such as fill, stroke, alignment, frame, borders, and size to adjust the circle according to their requirements.

Example

The following example make a Circle that is purple:

var body: some View {
Circle()
.fill(.purple)
.frame(width: 200, height: 200)
}

The above code generates a circle with a dimension of 200x200 points. This will display the following:

Circle

All contributors

Looking to contribute?

Learn SwiftUI on Codecademy