4

I like to build an old styled macOS app, not an iOS app! Therefore I need a list with a light grey background header row with the titles of the column. Usualy the user can resize each column by dragging the end of the header column around. But how can I set it with SwiftUI?

I read a lot about iOS and manually setting some text (titles/headers) above. But the intention is to use a build-in functionality, that this title belongs to a column and when changing the width of the title, the column is also changed. Also a double click will sort the entire list accordingly to the clicked column up or down. The width of the columns will also automatically fit the content.

Where is the property to set all these features?

1 Answer 1

2

SwiftUI lists can have only one column. Xcode 13 adds a Table control for Mac apps. The Table control supports multiple columns, but it requires macOS 12.

To support earlier macOS versions, you can wrap AppKit views, such as NSTableView, in SwiftUI by creating a struct that conforms to NSViewRepresentable. Wrapping NSTableView should give you the Mac table view behavior you want.

SwiftUI does support Mac lists having the sidebar list style. Use SidebarListStyle as the list's style.

.listStyle(SidebarListStyle())
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.