Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/swift/17.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
作为内容传递给UIViewRepresentable时,SwiftUI文本动态类型不起作用_Swift_Swiftui - Fatal编程技术网

作为内容传递给UIViewRepresentable时,SwiftUI文本动态类型不起作用

作为内容传递给UIViewRepresentable时,SwiftUI文本动态类型不起作用,swift,swiftui,Swift,Swiftui,我正在基于以下代码创建自定义popover: 下面是我使用所需内容创建popover的代码: @ScaledMetric(relativeTo: .body) var popoverHeight = 200 @State var open = false var popoverText: some View { Color.blue .edgesIgnoringSafeArea(.all) .overlay( VStack(ali

我正在基于以下代码创建自定义popover:

下面是我使用所需内容创建popover的代码:

@ScaledMetric(relativeTo: .body) var popoverHeight = 200
@State var open = false

var popoverText: some View {
    Color.blue
        .edgesIgnoringSafeArea(.all)
        .overlay(
            VStack(alignment: .center, spacing: 16) {
                Text("Testing text. Testing text. Testing text. Testing text. Testing text. Testing text. Testing text. Testing text.")
                    .font(.body)
                    .fontWeight(.semibold)
                    .foregroundColor(.white)
                Spacer()
            }
            .padding(.all, 16)
        )
}

var body: some View{
    VStack
    {
      WithPopover(showPopover: $open,
            popoverSize: CGSize(width: 300, height: popoverHeight),
            content: {
                 Button(action: { self.open.toggle() }) {
                    Image(systemName: "info.circle.fill")
                      .foregroundColor(.theme)
                        }
                    },
                    popoverContent: {
                        popoverText
                    }
                )
    }
运行时,在预览/模拟器中更改动态类型时,字体为“body”的文本不会动态缩放

知道为什么将文本作为内容传递给可表示的视图不能正确缩放它吗?它是否与popover视图控件大小约束有关