【发布时间】:2019-12-19 02:12:57
【问题描述】:
我试图让我的背景视图跨越 Apple Watch 外形尺寸上按钮的整个区域。
struct SurveyView: View {
var body: some View {
Button(action: {
print("Test tapped.")
}) {
HStack {
Text("Test")
.fontWeight(.semibold)
}
.frame(minWidth: 0, maxWidth: .infinity)
.padding()
.foregroundColor(.white)
.background(LinearGradient(gradient: Gradient(colors: [.green, .blue]), startPoint: .leading, endPoint: .trailing))
}
}
}
如何让背景跨越整个 Button?
更新:原来我的问题也与处于列表视图中有关。设置蒙版并不能完全解决它。
struct SurveyView: View {
var body: some View {
List() {
Button(action: {
print("Test tapped.")
}) {
Text("Test")
.fontWeight(.semibold)
}
.background(Color.orange)
.mask(RoundedRectangle(cornerRadius: 24))
}
}
}
【问题讨论】:
标签: swift swiftui apple-watch watchos