SwiftUI by Apple | Customize views with properties — Views, structures, and properties
🚀 #3 Excited to share more insights from my journey with Develop in Swift (SwiftUI) by Apple! Let’s keep the momentum going as we delve into the Customize views with properties.
📌 Topic: Customize views with properties — Views, structures, and properties
Description: Create a SwiftUI app by building custom views to make a multiday weather forecast.
🔗 Tutorial Link: https://developer.apple.com/tutorials/develop-in-swift/customize-views-with-properties
📝 Subtopics:
- Create New Project
- Setting a New Project
- Prototyping a view
— Use of #Preview
— SF Symbols App
— .foregroundStyle(.yellow) modifier
— VStack, HStack, Image, Text
— .padding modifier
— .font(Font.largeTitle)
— .fontWeight(Font.Weight.medium) - Extract subview using Xcode menu
- Creating a Custom View (DayForecast)
— Encapsulate:
— Properties
— Computed Properties - Compiling time error
— “No exact matches in call to initializer,” - Use of Properties
— String
— Bool
— Int
🔍 Key Insights:
In this tutorial you will be creating a simple Weather Forecast app. I’m still thinking that it would be easy to work in a Playground, but fortunately in this tutorial all the steps are very clear, another thing that maybe you could not do using Playground would be extract subview for create a new SwiftUI.
Maybe it would be good define DayForecast as DayForecastView because it is a view. I think that is a good practice. But it is missed in this tutorial.
Maybe it would be good mention that an Struct automatically creates the initializer.
Also I see that sometimes is possible to use an implicit code style (.foregroundStyle(.red)), but in this examples I can see explicit implementations (.foregroundStyle(Color.red)).
A compiler time error is when the Xcode let you know an error in your code, maybe a short explanation of what is a compiler error would be beneficial.
Another thing that I saw it was that Apple does not use access controls like using private in computed propeties, maybe it would be good a short explanation of a computed property (you can think on that as a function without parameters).
And finally some questions at the end of this tutorial I liked that :).
#AppleJourney #SwiftDevelopment #AlwaysLearning #mobile #ios #apple