🐞mismatching types
╱🚧 under construction
SwiftUI ⟩ view ⟩ modifier ⟩ rendering ⟩ .clipShape ⟩ 🐞 mismatching types
Text("Clipped text in a circle")
.frame(width: 50, height: 50)
// 🐞 mismatching types
.clipShape(isOn ? Circle() : Capsule())
Result values in '?:
' expression have mismatching types 'some Shape
' (Circle
) and 'some Shape
' (Capsule
).
👉 解決方案: AnyShape, 用 enum 封裝不同型別, has non-Sendable type
SwiftUI ⟩ View fundamentals ⟩ View ⟩ rendering modifiers
.clipShape(_:style:) : .cornerRadius() 已經廢止 (deprecated),用此 clipShape 代替
.clipped(antialiased:):將 view 突出 frame 的部分裁掉
Last updated
Was this helpful?