【发布时间】:2020-07-05 14:20:39
【问题描述】:
我有以下看法:
struct ContentView: View {
var body: some View {
LinearGradient(gradient: Gradient(colors: [.blue, .red]), startPoint: .topTrailing, endPoint: .bottomLeading)
.cornerRadius(16)
.frame(width: 140, height: 140)
.contextMenu {
Button("", action: {})
}
}
}
但是,当调用 ContextMenu 时,边缘不圆:
我已经尝试了几件事,例如:
- 应用
clipShape修饰符将其剪辑到RoundedRectangle - 将渐变包装为 RoundedRectangle 视图的背景
- 使用 Color 而不是 LinearGradient(按预期工作,但不是我需要的)
但是没有一个工作。任何建议将不胜感激,谢谢!
【问题讨论】:
标签: swift view swiftui contextmenu gradient