mic*_*ica 6 swiftui swiftui-navigationlink
我有一个 NavigationView 列表。
在黑暗模式下,雪佛龙(红色圆圈)几乎不可见。
struct ContentView: View {
var body: some View {
NavigationView{
List {
Line(text: "Line 1")
Line(text: "Line 2")
Line(text: "Line 3",selected: true)
Line(text: "Line 4")
Line(text: "Line 5")
}
}
}
}
struct Line: View {
var text :String
var selected = false
@Environment(\.colorScheme) var colorScheme
var body: some View {
NavigationLink(destination: Text("D")) { Text(text)}
.listRowBackground(selected ? Color.blue : Color(.systemBackground))
.foregroundColor(selected ? Color.white : Color(.label))
.onTapGesture(perform: {print ("tap")
} )
}
}
Run Code Online (Sandbox Code Playgroud)
标准 V 形符号不是光栅图像的符号,这里是
这就是为什么它不会对任何颜色变化修饰符做出反应。
解决办法,禁用标准的雪佛龙并使用自己的,自定义的,(列表的行为是相同的),如下所示
HStack {
Text(text)
NavigationLink(destination: Text("D")) { EmptyView() } // disabled !
Image(systemName: "chevron.right") // << custom !!
.foregroundColor(Color.red) // any color !!!
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
799 次 |
| 最近记录: |