[英]SwiftUI - Using drawingGroup() disables TextField
.drawingGroup
将整个视图层次结构转换为图像,因此在此之后您不能使用TextField
(或任何其他控件)作为活动控件,因为您在屏幕上看到的只是图像。
它按记录工作:
/// Composites this view's contents into an offscreen image before final
/// display.
///
/// Views backed by native platform views don't render into the image.
/// Instead, they log a warning and display a placeholder image to highlight
/// the error.
///
/// - Parameters:
/// - opaque: A Boolean value that indicates whether the image is opaque.
/// If `true`, the alpha channel of the image must be one.
/// - colorMode: The working color space and storage format of the image.
/// - Returns: A view that composites this view's contents into an offscreen
/// image before display.
public func drawingGroup(opaque: Bool = false, colorMode: ColorRenderingMode = .nonLinear) -> some View
对此的解决方案不是将.drawingGroup
用于活动控件,而仅用于没有用户交互的 UI 元素。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.