如何在 SwiftUI 中使用矩形创建文件夹?

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

我目前正在开发一个应用程序,我想为其创建某种文件夹,我不想使用图像,所以我想使用矩形来完成,但恐怕我不会太聪明了,所以我在这里问你是否可以帮助我。

提前非常感谢。

这是我当前的代码:

ZStack{
            
            VStack{
                RoundedRectangle(cornerRadius: 25)
                    .fill(Color("marineblau"))
                    .frame(width: 100, height: 80)
            }
            
            VStack{
                RoundedRectangle(cornerRadius: 25)
                    .fill(Color("blau"))
                    .frame(width: 150, height: 110)
            }
        }
swiftui rectangles
1个回答
1
投票

喜欢这样吗?

    ZStack{

        VStack {

            RoundedRectangle(cornerRadius: 5)
                .fill(.black) // Change the color
                .frame(width: 60, height: 80)
                .offset(x: -45, y: -30)
        }

        VStack {
            RoundedRectangle(cornerRadius: 10)
                .fill(.black) // Change the color
                .frame(width: 150, height: 80)
                .offset(y: -25)
        }

        VStack {
            RoundedRectangle(cornerRadius: 10)
                .fill(.blue)  // Change the color
                .frame(width: 150, height: 110)
        }

        VStack {
            Image(systemName: "chart.bar.xaxis.ascending")
            Text("Name")

        }
        .font(.title3.bold())
        .foregroundStyle(.white)

    }

或者像这样:

    ZStack{
        BackgroundView()


        VStack {
            RoundedRectangle(cornerRadius: 5)
                .fill(.black) // Change the color
                .frame(width: 60, height: 80)
                .offset(x: -45, y: -32)
                .overlay(
                    Path { path in
                        path.move(to: CGPoint(x: 0, y: 50))
                        path.addLine(to: CGPoint(x: 0, y: 0))
                        path.addLine(to: CGPoint(x: 50, y: 50))
                        path.closeSubpath()
                    }
                        .fill(Color.black)
                        .offset(x: 12, y: -32)
                )
        }

        VStack {
            RoundedRectangle(cornerRadius: 10)
                .fill(.black) // Change the color
                .frame(width: 150, height: 80)
                .offset(y: -25)
        }

        VStack {
            RoundedRectangle(cornerRadius: 10)
                .fill(.blue)  // Change the color
                .frame(width: 150, height: 110)
        }

        VStack {
            Image(systemName: "chart.bar.xaxis.ascending")
            Text("Name")

        }
        .font(.title3.bold())
        .foregroundStyle(.white)

    }

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