如何在另一个图像视图的一角添加系统图像

时间:2019-12-10 21:04:21

标签: ios swiftui

我想知道如何在图像的一个角上添加图像系统。

Here is an example

我不知道该怎么做,如果有人能对此有所了解,那将是一种乐趣。

1 个答案:

答案 0 :(得分:0)

您需要一个带主图像的ZStack和一个带图标的按钮。您可以定义如何对齐图像-在这种情况下为.topTrailing

struct LayeredImage: View {
    var body: some View {
        ZStack(alignment: .topTrailing) {
            Image("card")
                .resizable()
                .aspectRatio(contentMode: .fit)
                .padding(6.0)
            Button(action: { }) {
                Image(systemName: "ellipsis.circle.fill")
                    .foregroundColor(.gray)
                    .font(.largeTitle)
            }
        }   .padding()
    }
}

the result

相关问题