[英]SwiftUI View displayed with blue background
我正在嘗試重現 Apple 教程(組合復雜接口),但我遇到了一個非常奇怪的問題。 我的CategoryItem
視圖顯示為藍框。
如果我刪除了包裹它的NavigationLink
,一切正常,但使用它就不行了。
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)
或者你可以試試這個:
NavigationView {
NavigationLink(destination: Text("Detail view here")) {
Image("YourImage")
}
.buttonStyle(PlainButtonStyle())
}
renderingMode(.original)
是為我做的; .accentColor(Color.clear)
使圖像不可見(我最好的解釋是因為它沒有透明度)。
NavigationView {
NavigationLink(destination: Text("Detail view here")) {
Image("YourImage")
.renderingMode(.original)
}
}
正如上面提到的答案, How to disable the overlay color for images inside Button and NavigationLink也是一個很好的文章。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.