Skip to content

Instantly share code, notes, and snippets.

@js
Created March 13, 2023 12:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save js/21f8b7871efe85279fc71af970895dbc to your computer and use it in GitHub Desktop.
Save js/21f8b7871efe85279fc71af970895dbc to your computer and use it in GitHub Desktop.
import SwiftUI
@available(iOS, deprecated: 16.0, message: "Use SwiftUI.scrollContentBackground()")
struct HidesScrollContentBackground: ViewModifier {
init() {
if #unavailable(iOS 16.0) {
// beware, affects the app-global appearance proxy:
// UITableView.appearance().backgroundColor = .clear
}
}
func body(content: Content) -> some View {
if #available(iOS 16.0, *) {
content
.scrollContentBackground(.hidden)
} else {
content // Boo
}
}
}
@available(iOS, deprecated: 16.0, message: "Use SwiftUI.scrollContentBackground()")
public extension View {
@ViewBuilder func hidesScrollContentBackground() -> some View {
modifier(HidesScrollContentBackground())
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment