SwiftUI导航链接箭头

rsaldnfx  于 2023-06-21  发布在  Swift
关注(0)|答案(1)|浏览(143)

我有一个问题,箭头总是显示。我已经尝试过.buttonsytel(PlainButtonStyle())或类似的东西。也使用.frame(0).opacity(0)或.hidden,但未显示任何内容。我怎样才能把箭藏起来呢?

List {
                    ForEach(projectListVM.projects, id: \.id) { project in
                        NavigationLink(destination: ProjectTabViewScreen(project: project)){
                         
                            ProjectListCardDesign(project: project)
 }
                        .listRowSeparator(.hidden)
                            
                            
                    }.onDelete(perform: deleteProject)
            }.listStyle(.plain)
import SwiftUI

struct ProjectListCardDesign: View {
    
    let project: ProjectViewModel
    
    
   
    
    var body: some View {
        
        HStack {
            if !project.symbol.isEmpty {
                Image(systemName: project.symbol)
                    .font(.largeTitle)
                    .padding(.all, 10)
                    .background(Color.blue.opacity(0.2))
                    .clipShape(Circle())
                    .padding(.trailing, 10)
            }
            
            VStack(alignment: .leading, spacing: 5) {
                Text(project.title)
                    .font(.title3)
                    .fontWeight(.bold)
                    .foregroundColor(.primary)
                    
                if !project.info.isEmpty {
                    Text(project.info)
                        .font(.caption)
                        .foregroundColor(.secondary)
                }
            }
            Spacer()
            
            VStack {
                

                switch project.prio {
                case 1:
                    RoundedRectangle(cornerRadius: 10)
                        .fill(Color.clear)
                        .frame(width: 15, height: 40)
                case 2:
                    RoundedRectangle(cornerRadius: 10)
                        .fill(Color.green)
                        .frame(width: 15, height: 40)
                case 3:
                    RoundedRectangle(cornerRadius: 10)
                        .fill(Color.orange)
                        .frame(width: 15, height: 40)
                case 4:
                    RoundedRectangle(cornerRadius: 10)
                        .fill(Color.red)
                        .frame(width: 15, height: 40)
                default:
                    RoundedRectangle(cornerRadius: 10)
                        .fill(Color.clear)
                        .frame(width: 15, height: 40)
                }
            }
            .padding(.leading, 10)
        }
        .padding()
        .background(Color(.systemGray6))
        .cornerRadius(15)
        .shadow(color: Color.black.opacity(0.2), radius: 7, x: 0, y: 2)      
        
    }
}

会是什么原因呢?我已经试过所有的方法了。开始的时候他不知道,或者他不知道更多。

v8wbuo2f

v8wbuo2f1#

只是去掉V形标记不是标准行为。但是如果你仍然想这样做,那么就像这样在.background()修饰符中使用NavigationLink

NavigationStack{
    List {
        ForEach(projectListVM.projects, id: \.id) { project in
            ProjectListCardDesign(project: project)
                .background (
                    NavigationLink("", destination: ProjectTabViewScreen(project: project))
                )
                .listRowSeparator(.hidden)
         }.onDelete(perform: deleteProject)
    }.listStyle(.plain)
}

在这种情况下,NavigationLink将位于List项的背景中。NavigationLink中的空字符串“”需要有一个Label。这工作现在就像你期望的,而不必显示一个V形

相关问题