Type Safely

Type Safely

Share this post

Type Safely
Type Safely
Using Enum Instead of Struct For SwiftUI Views

Using Enum Instead of Struct For SwiftUI Views

Daily Coding Tip 078

Millie Sturgeon's avatar
Millie Sturgeon
May 03, 2022
∙ Paid

Share this post

Type Safely
Type Safely
Using Enum Instead of Struct For SwiftUI Views
Share
Image by fijidji from Pixabay

Here I have a SwiftUI view called EnumView that is an enum rather than a struct.

It has three cases: red, blue and green.

For each case it unsurprisingly returns a Color, which conforms to View.

Keep reading with a 7-day free trial

Subscribe to Type Safely to keep reading this post and get 7 days of free access to the full post archives.

Already a paid subscriber? Sign in
© 2025 Type Safely
Privacy ∙ Terms ∙ Collection notice
Start writingGet the app
Substack is the home for great culture

Share