SwiftUI LazyVStack vs VStack

If we want to load the content into memory when we need it, we can use LazyVStack. It is particularly useful when we have large list of contents inside a scrollview.

Here’s how our regular VStack looks like:

VStack has 1000 Text content in it and the background color of VStack is blue:

And this is the memory report I have at first launch of my simulator:

Now back to LazyVStack:

Exactly same setup, I only replaced VStack with LazyVStack and here’s the result:

See that LazyVStack has flexible width and it covers all the screen whereas VStack fits in its context. With LazyVStack, in this example, we can scroll vertically by dragging anywhere on the screen.

And the memory report at first launch of my simulator:




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

Recommended from Medium

Corner radius in Swift

Monthly I18n And L10n Roundup — October 2016

Device Selection for iOS App Testing

Swift JSON parser using Generics

Apple coordinate system

Taopiaopiao iOS Client: Local Video Proxy and Cache Solution

Manual Image Crop on Xamarin.Forms using SkiaSharp[Part 2]

@State Property Wrapper Explained

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
Hasancan Akgündüz

Hasancan Akgündüz

iOS Developer

More from Medium

What can go wrong when using custom fonts in SwiftUI

Filtering Operators in Combine Framework

Filter in Swift — Best Practices

SwiftUI StateObject and ObservedObject