swiftui剪切后未剪切的图像

问题描述 投票:0回答:2

[嗨,我在SwiftUi中遇到图片问题,我的布局是:e

图像和适合度是可区分的,但是当我单击适应度时,打开​​图像页面。

这是我的代码:

VStack {
    HStack(alignment: .center) {
        NavigationLink(destination: FullNewsListView(category: "Fitness")) {
            Text("Fitness")
                .foregroundColor(Color("#29B1B3"))
                .font(Font.custom("AvenirNextLTPro-Bold", size: 20))
            Image("forward_blue")
        }
        Spacer()
        }
    .padding(.bottom, 10)
    VStack(alignment: .leading, spacing: 10) {
        HStack {
            URLImage(URL(string: "http://myPhoto")!) { proxy in
                proxy.image
                    .renderingMode(.original)
                    .resizable()
                    .aspectRatio(contentMode: .fill)
                    .frame(minWidth: 0, maxWidth: .infinity)
                    .frame(height: 180)
                    .cornerRadius(12)
                    .clipped()

            }

        }
        HStack {
            Text(api.newsFitnessHome.news!.title)
                .foregroundColor(.black)
                .font(Font.custom("AvenirNextLTPro-Demi", size: 15))
                .opacity(0.8)
                .lineSpacing(5)
                .lineLimit(2)
                .fixedSize(horizontal: false, vertical: true)
            Spacer()
        }
    }
}
.padding(.horizontal, 30)
uiimageview swiftui
2个回答
1
投票

无法测试,因为没有所有可用的组件,但是我想这是由于图像命中区域所致,请参阅下面的一些假设

URLImage(URL(string: "http://myPhoto")!) { proxy in
    proxy.image
        .renderingMode(.original)
        .resizable()
        .aspectRatio(contentMode: .fill)
        .frame(minWidth: 0, maxWidth: .infinity)
        .frame(height: 180)
        .cornerRadius(12)
        .clipped()
        .contentShape(Rectange())      // try this
}
//.contentShape(Rectange())      // or here

0
投票

您可以尝试这种设置:

        VStack {
            HStack(alignment: .center) {
                NavigationLink(destination: FullNewsListView(category: "Fitness")) {
                    HStack {
                        Text("Fitness")
                            //   .foregroundColor(Color("#29B1B3"))
                            .font(Font.custom("AvenirNextLTPro-Bold", size: 20))
                        Image("forward_blue")
                        Spacer()
                    }
                }
                Spacer()
            }.padding(.bottom, 10)
        }

....

也.foregroundColor(Color(“#29B1B3”))对我不起作用。

© www.soinside.com 2019 - 2024. All rights reserved.