在ios14、xcode12 swiftUI中对齐不工作

在ios14、xcode12 swiftUI中对齐不工作,swift,swiftui,alignment,frame,ios14,Swift,Swiftui,Alignment,Frame,Ios14,我的对齐在xcode12 ios14中不起作用,但是,我在xcode11.5中有相同的代码,一切都很好。每当我在内容对齐中添加.frame viewModifier时,它都不在中间,这是一个bug还是API发生了变化?下面是代码:请在xcode12中查看它,仅限ios14 struct ContentView: View { var body : some View { GeometryReader { geo in

我的对齐在xcode12 ios14中不起作用,但是,我在xcode11.5中有相同的代码,一切都很好。每当我在内容对齐中添加.frame viewModifier时,它都不在中间,这是一个bug还是API发生了变化?下面是代码:请在xcode12中查看它,仅限ios14

struct ContentView: View {
    
    var body : some View {
       
        GeometryReader { geo in
            
            Capsule()
                .fill(Color.red)
                .frame(height: 50)
            
        }
        
    }
    
    
   
}
这也不起作用:

struct ContentView: View {
    
    var body : some View {
        ZStack(alignment: .center) {
        GeometryReader { geo in
            
            Capsule()
                .fill(Color.red)
                .frame(height: 50)
            
        }
        
    }
    }
    
   
}
这不起作用:

struct ContentView: View {
    
    var body : some View {
        ZStack(alignment: .center) {
        GeometryReader { geo in
            
            Capsule()
                .fill(Color.red)
                .frame(height: 50, alignment: .center)
            
        }
        
    }
    }
    
   
}

每当我移除GeometryReader时,一切都正常工作,但我想要GeometryReader,以下两种情况下都会为您提供

ZStack {
    Capsule()
        .fill(Color.red)
        .frame(height: 50)
}.frame(maxWidth: .infinity, maxHeight: .infinity)

是的,
GeometryReader
的行为是不同的,但很难说哪一个更正确。我建议不要依赖于隐式布局,而是显式地按照您的意愿进行布局。向苹果公司提交反馈,他们可能会回复。我是否应该在他们使用xcode12的教程之后返回xcode11.5 Im?最佳解决方案是什么?xcode12、swiftui2.0或ios14存在it问题?我的问题与OP相同;这个解决方案没有解决问题。还有什么值得一试的吗?