该.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
Run Code Online (Sandbox Code Playgroud)
对此的解决方案不适.drawingGroup用于活动控件,而仅适用于没有用户交互的 UI 元素。
| 归档时间: |
|
| 查看次数: |
442 次 |
| 最近记录: |