The inset grouped list style has a top inset that adds extra space between the navigation bar title and the list rows. Use introspect to remove this space on UITableView and UICollectionView (for iOS 16). Sections completely ignore the introspect changes, so add a section header which removes the list row insets. Signed-off-by: kingbri <bdashore3@proton.me>
28 lines
766 B
Swift
28 lines
766 B
Swift
//
|
|
// InlinedList.swift
|
|
// Ferrite
|
|
//
|
|
// Created by Brian Dashore on 9/4/22.
|
|
//
|
|
// Removes the top padding on lists for iOS 16
|
|
// Use UITableView.appearance().contentInset.top = -20 for iOS 15 and below in the App file
|
|
//
|
|
|
|
import SwiftUI
|
|
import Introspect
|
|
|
|
struct InlinedList: ViewModifier {
|
|
func body(content: Content) -> some View {
|
|
if #available(iOS 16, *) {
|
|
content
|
|
.introspectCollectionView { collectionView in
|
|
collectionView.contentInset.top = -20
|
|
}
|
|
} else {
|
|
content
|
|
.introspectTableView { tableView in
|
|
tableView.tableHeaderView = UIView(frame: CGRect(x: 0, y: 0, width: 0, height: 20))
|
|
}
|
|
}
|
|
}
|
|
}
|