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      

BUILD THE ULTIMATE PORTFOLIO APP Most Swift tutorials help you solve one specific problem, but in my Ultimate Portfolio App series I show you how to get all the best practices into a single app: architecture, testing, performance, accessibility, localization, project organization, and so much more, all while building a SwiftUI app that works on iOS, macOS and watchOS.

Get it on Hacking with Swift+

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.