我有以下看法:
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视图的背景包装
- 使用颜色而不是线性渐变(它按预期工作,但不是我需要的)
然而,这些都不起作用。任何建议都将不胜感激,谢谢!