圆形 LinearGradient 上的 ContextMenu 在 SwiftUI 中产生尖锐的边缘

ContextMenu on a rounded LinearGradient produces sharp edges in SwiftUI

我有以下看法:

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 时,边缘不是圆角的:

我尝试了几种方法,例如:

但是 none 有效。任何建议将不胜感激,谢谢!

.frame(...)后添加如下代码:

.contentShape(RoundedRectangle(cornerRadius: 16, style: .continuous))