我正在創建一個透明List的行和節標題。
但是,只要行在節標題下滑動,它就會自動具有背景模糊。我理解這種情緒,但想退出。

有沒有人設法以某種方式隱藏它?讓部分標題背景完全透明?
struct HeaderView: View {
var body: some View {
ZStack {
Image("Map")
.opacity(0.5)
List {
Section(
header: VStack {
Text("Section 1")
.font(.system(size: 40))
.frame(height: 60)
},
content: {
ForEach(1...20, id: \.self) { eachRowIndex in
Text("Row \(eachRowIndex)")
.listRowBackground(Color.clear)
}
}
)
}
.listStyle(.plain)
.padding(.top, 40)
}
}
}
最好是 iOS 13 SwiftUI,但我很好奇 UIKit 中是否也與它有關。
uj5u.com熱心網友回復:
將空視圖添加到UITableViewHeaderFooterView
struct HeaderView: View {
init() {
UITableViewHeaderFooterView.appearance().backgroundView = UIView() // here
}
// Other code
uj5u.com熱心網友回復:
對于 iOS 13,我需要 introspectUITableViewHeaderFooterView并在backgroundView那里手動設定(這也需要一個Introspect擴展)。
struct ContentView: View {
init() {
UITableViewHeaderFooterView.appearance().backgroundView = UIView()
}
var body: some View {
List {
Section(
header: HStack {
...
}
.introspectTableViewHeaderFooterView {
$0.backgroundView = UIView()
},
content: {
ForEach {
...
}
}
)
}
.listStyle(.plain)
}
}
extension View {
public func introspectTableViewHeaderFooterView(customize: @escaping (UITableViewHeaderFooterView) -> Void) -> some View {
introspect(selector: TargetViewSelector.ancestorOrSiblingContaining, customize: customize)
}
}
轉載請註明出處,本文鏈接:https://www.uj5u.com/qiye/447186.html
上一篇:洗掉部分標題上方的額外填充?
下一篇:從部分中洗掉行
