Preview in SwiftUI

Once you have finished the SwiftUI code, it is always a good idea to preview it before implement any function code. Luckily, such feature is natively supported by SwiftUI — PreviewProvider:

Example of showing previews:

The preview:

Or if you prefer, we can use the fixed size:

Preview:

Originally published at https://needone.app on December 18, 2020.

Reference:

https://needone.app/preview-in-swiftui/

--

--

--

needone.app

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

What is SwiftUI? Benefits and Drawbacks

Expressive View Model Unit Tests at Grailed

How to Use Live Previews in UIKit

SwiftUI: Add a nice header skew animation to your views

Swift Core Data Preload at App First Launch

iOS 16: Everything You Need to Know

RxSwift and Reactive Programming

Swift Runtime with Sourcery

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Needone App

Needone App

needone.app

More from Medium

Embed UIView in SwiftUI, define communication both ways

Map & User Location Tracking in SwiftUI

SwiftUI | Classes VS Struct | Why to choose Structs for swiftUI Views instead of Classes?

How to: use WKWebView on Mac with SwiftUI