[英]SwiftUI Image clipped to shape has transparent padding in context menu
我相信適用於所有場景的正確解決方案是在 contentShape 中設置第一個參數(種類):
func contentShape<S>(_ kind: ContentShapeKinds, _ shape: S)
將其設置為 .contextMenuPreview ,這將適用於所有形狀:
Image("leaf")
.resizable()
.aspectRatio(contentMode: .fill)
.frame(width: 300, height: 300)
.clipShape(Circle())
.contentShape(ContentShapeKinds.contextMenuPreview, Circle())
.contextMenu {
Text("Menu Item")
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.