如何在 SwiftUI 的 ZStack 中相对于另一张图像定位一张图像?
How can I position 1 image relative to another in a ZStack in SwiftUI?
我在 ZStack 中有 2 张图片。如何将图片“x.circle”定位到图片“person.fill”的右上角?
ZStack {
Image(systemName: "person.fill")
.font(.system(size: 200))
Image(systemName: "x.circle")
.font(.system(size: 20, weight: .bold))
.foregroundColor(.red)
.background(.white)
.clipShape(Circle())
}
使用ZStack(alignment: .topTrailing
:
ZStack(alignment: .topTrailing) { // here
Image(systemName: "person.fill")
.font(.system(size: 200))
Image(systemName: "x.circle")
.font(.system(size: 20, weight: .bold))
.foregroundColor(.red)
.background(.white)
.clipShape(Circle())
}
我在 ZStack 中有 2 张图片。如何将图片“x.circle”定位到图片“person.fill”的右上角?
ZStack {
Image(systemName: "person.fill")
.font(.system(size: 200))
Image(systemName: "x.circle")
.font(.system(size: 20, weight: .bold))
.foregroundColor(.red)
.background(.white)
.clipShape(Circle())
}
使用ZStack(alignment: .topTrailing
:
ZStack(alignment: .topTrailing) { // here
Image(systemName: "person.fill")
.font(.system(size: 200))
Image(systemName: "x.circle")
.font(.system(size: 20, weight: .bold))
.foregroundColor(.red)
.background(.white)
.clipShape(Circle())
}