我有一個可以拖動的圓角視圖。一旦開始拖動,角落里就會出現一個白色的半透明背景視圖。如何洗掉?
我嘗試使用.contentShape
,.clipShape
但這并不能解決問題。在 UIKit 中,我曾經UIDragPreviewParameters
剪輯預覽,但在 SwiftUI 中似乎沒有這樣的東西。有任何想法嗎?
代碼:
RoundedRectangle(cornerRadius: 25, style: .continuous)
.foregroundColor(.blue)
.frame(width: 100, height: 100)
.contentShape(RoundedRectangle(cornerRadius: 25, style: .continuous))
.onDrag {
NSItemProvider()
}
uj5u.com熱心網友回復:
您需要.dragPreview
輸入內容形狀,例如
RoundedRectangle(cornerRadius: 25, style: .continuous)
.foregroundColor(.blue)
.frame(width: 100, height: 100)
.contentShape(.dragPreview, RoundedRectangle(cornerRadius: 25, style: .continuous))
轉載請註明出處,本文鏈接:https://www.uj5u.com/net/470513.html
上一篇:終端在啟動時顯示環境變數
下一篇:C# 訊息佇列demo