How to format text inside text views - SwiftUI by Example

preview_player
Показать описание
SwiftUI’s text views have an optional `formatter` parameter that lets us customize the way data is presented inside the label. This is important because often values are updated for us when something happens in our program, so by attaching a formatter SwiftUI can make sure our data looks right on our behalf.
Рекомендации по теме
Комментарии
Автор

Questions? Comments? Tweet me @twostraws.

twostraws
Автор

Just a note: if you follow the example, you'll get something like "2019 M07 1" in static preview, once you click the play button to run live preview, the date will be displayed correctly ""July 1, 2019"

legolas
Автор

Thanks. Why does the 2nd DateFormatter have () while the first one does not? Also why's there a () at the end of static let?

SevenDeMagnus
Автор

How can you write static let for computed properties? Shouldnt it be static var?

rapidrohith
Автор

Thanks for videos about SwiftUI. I want to know why you use "Self.taskDateFormat" with capital S. I do not get it. Could you explain?

funkygeek
Автор

Arrrgh! Formatting data in the view? Please don't. That's the view model's responsibility. The view is responsible for its own appearance not the data's appearance.

vjosullivan
visit shbcf.ru