UPGRADE YOUR SKILLS: Learn advanced Swift and SwiftUI on Hacking with Swift+! >>

How much space do I have?

Forums > SwiftUI

I want to display a number of rows of calculated data, so that all are visible without scrolling. So if there is room, I want to display all 10 rows; but if there isn't, I will display only the most useful 5.

I can do it by wrapping in a GeometryReader and checking for (geometry.size.height>700), and it works. I strongly suspect there's a more elegant way, though, that won't break if the user is using large fonts or something like that.

Any ideas gratefully received.

Jeremy

2      

are you using a for each or a list?

There is nothing wrong with using a geometry reader where you have to. I dont think the list has an adaptive resizing option. LazyGrid view does though.

2      

I'm using ForEach: I'll look at LazyGrid. Thanks.

Jeremy

2      

TAKE YOUR SKILLS TO THE NEXT LEVEL If you like Hacking with Swift, you'll love Hacking with Swift+ – it's my premium service where you can learn advanced Swift and SwiftUI, functional programming, algorithms, and more. Plus it comes with stacks of benefits, including monthly live streams, downloadable projects, a 20% discount on all books, and free gifts!

Find out more

Sponsor Hacking with Swift and reach the world's largest Swift community!

Archived topic

This topic has been closed due to inactivity, so you can't reply. Please create a new topic if you need to.

All interactions here are governed by our code of conduct.

 
Unknown user

You are not logged in

Log in or create account
 

Link copied to your pasteboard.