SwiftUI 视图显示为蓝色背景 [英] SwiftUI View displayed with blue background
本文介绍了SwiftUI 视图显示为蓝色背景的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试重现 Apple 教程(编写复杂接口),但遇到了一个非常奇怪的问题.我的 CategoryItem
视图显示为蓝框.
I'm trying to reproduce the Apple tutorial(Composing Complex Interfaces) and I have a very weird problem. My CategoryItem
view is being displayed as a blue frame.
如果我删除包装它的 NavigationLink
,一切正常,但使用那个就不行了.
If I remove the NavigationLink
which wraps it, everything works fine but with that one it doesn't.
struct CategoryRow: View {
var categoryName: String
var items: [Landmark]
var body: some View {
VStack(alignment: .leading) {
Text(self.categoryName)
.font(.headline)
.padding(.leading, 15)
.padding(.top, 5)
ScrollView(.horizontal, showsIndicators: false) {
HStack(alignment: .top, spacing: 0) {
ForEach(self.items) { landmark in
NavigationLink(
destination: LandmarkDetail(
landmark: landmark
)
) {
CategoryItem(landmark: landmark)
}
}
}
}.frame(height: 185)
}
}
}
推荐答案
NavigationLink
默认有蓝色强调色,只需调用 .accentColor(Color.clear)
它
NavigationLink
has a blue accent color by default, just call .accentColor(Color.clear)
on it
或者你可以试试这个:
NavigationView {
NavigationLink(destination: Text("Detail view here")) {
Image("YourImage")
}
.buttonStyle(PlainButtonStyle())
}
这篇关于SwiftUI 视图显示为蓝色背景的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文