![](/img/trans.png)
[英]SwiftUI adding personal alert view in NavigationView, the back button doesn't work with Xcode 12 iOS14
[英]Alignment not working in ios14, xcode12 swiftUI
我的 alignment 在 xcode12 ios14 中不起作用,但是,我在 xcode11.5 中有相同的代碼,一切都很好。 每當我將.frame viewModifier 添加到內容 alignment 不在中心時,是錯誤還是 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)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.