Circle

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

Contributors

Interested in helping build Docs? Read the Contribution Guide or share your thoughts in this feedback form.

Learn SwiftUI on Codecademy