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

Is it possible to make a list with sections that scroll like normal rows?

Forums > SwiftUI

I mean not floating sections.

Apparently you can do that to tableviews by using this code

let dummyViewHeight = CGFloat(40)
self.tableView.tableHeaderView = UIView(frame: CGRect(x: 0, y: 0, width: self.tableView.bounds.size.width, height: dummyViewHeight))
self.tableView.contentInset = UIEdgeInsets(top: -dummyViewHeight, left: 0, bottom: 0, right: 0)

Any ideas for SwiftUI?

Thanks in advance.

3      

By scroll like normal do you mean that they are basically rows with different backrounds and fonts etc? You could fairly easily roll your own on that.

3      

Yes but that would be a hack, and no so beautiful. I mean, I would like them to continue to be sections but to be fixed in place, like titles for the rows of their sections, without floating and hanging at the top.

3      

Whats hacky about it? Section is defined as

public struct Section<Parent, Content, Footer> {

which means you have to supply the internal content youself and SwiftUI will make sure the section floats, or be collapsable. So you provide your own UI either way.

3      

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.