SwiftUI-使用drawingGroup()禁用TextField

问题描述 投票:0回答:1

我正在尝试改善自定义模态视图的动画性能。

通过使用.drawingGroup(),我设法做到了,但是我的TextField被禁用了。像这样:

enter image description here

并且我得到错误:'无法呈现PlatformViewRepresentableAdaptor <>的展平版本。

是否有解决此问题的方法?

注意:我使用的是标准TextField。

谢谢!

ios swift swiftui metal
1个回答
0
投票
它按记录的方式工作:

/// 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元素。

© www.soinside.com 2019 - 2024. All rights reserved.