NavigationLink中的图像无法渲染

“导航”链接中的图像仅显示为蓝色。点击图像确实可以将我们正确地导航到目的地。

代码:

public var body: some View {
    NavigationView {
        Image("1")
        .resizable()
        .scaledToFit()
    }
}

输出:

NavigationLink中的图像无法渲染

代码:

public var body: some View {
    NavigationView {
        NavigationLink(destination: Image("2")) {
            Image("1")
            .resizable()
            .scaledToFit()
        }
    }
}

输出:

NavigationLink中的图像无法渲染

hzhgch 回答:NavigationLink中的图像无法渲染

在撰写问题时,我意识到我需要正确设置渲染模式。以下内容可解决此问题:

public var body: some View {
    NavigationView {
        NavigationLink(destination: Image("2")) {
            Image("1")
            .renderingMode(.original)
            .resizable()
            .scaledToFit()
        }
    }
}
本文链接:https://www.f2er.com/3136845.html

大家都在问