我正在寻找有关使用SwiftUI实现以下目标的最佳方法的建议。
我有一个带有红色圆角矩形角的视图和一个子视图,该子视图是一个蓝色的矩形框,与父级的底部偏移。 1
但是,我希望掩盖第二个附图2中的阴影区域,使该区域显示为白色(即,删除蓝色阴影区域),并且不确定如何最好地做到这一点。
这是目前的代码:-
import SwiftUI
import Foundation
struct PupilCell : View {
var body : some View {
ZStack {
Rectangle().frame(height: 60.0, alignment: .bottom).foregroundColor(Color.blue).offset(x: 0.0, y: 50.0)
RoundedRectangle(cornerRadius: 25, style: .continuous).stroke(lineWidth: 2.0).fill(Color.red)
}
}
}
答案 0 :(得分:1)
这是可行的方法:
ZStack {
Rectangle().frame(height: 60.0, alignment: .bottom).foregroundColor(Color.blue).offset(x: 0.0, y: 50.0)
RoundedRectangle(cornerRadius: 25, style: .continuous).stroke(lineWidth: 2.0).fill(Color.red)
}.mask(RoundedRectangle(cornerRadius: 25, style: .continuous).fill(Color.black))