Код: Выделить всё
@ViewBuilder
func userNameOverlay() -> some View {
GroupBox {
Image(systemName: "person.circle.fill")
.font(.system(size: 60))
.foregroundStyle(.colorTextPrimary)
.padding()
Text("Enter Your Name")
.appTitle(withSpacing: true)
TextField("John Doe", text: $username)
.padding(12)
.background(.colorBackground)
.clipShape(.rect(cornerRadius: 16))
.shadow(radius: 1, x: 1, y: 1)
.padding(.bottom)
Button {
withAnimation {
vm.showUserNameOverlay = false
}
} label: {
Text("Save")
.padding(.vertical, 10)
.frame(maxWidth: .infinity)
.background(.accent)
.foregroundStyle(.colorBackground)
.fontWeight(.bold)
.clipShape(.rect(cornerRadius: 16))
}
}.padding(.horizontal)
.groupBoxStyle(.customStyle)
.transition(.move(edge: .bottom))
}
< /code>
Сначала это был Vstack с наложением, и теперь я переключился на Zstack, но все еще не работал, почему это? < /p>
ZStack(alignment: .bottom) {
ScrollView(showsIndicators: false) {
VStack {
main_views…
Spacer()
}.padding()
.foregroundStyle(.colorTextPrimary)
.blur(radius: vm.showUserNameOverlay ? 3 : 0)
.disabled(vm.showUserNameOverlay)
}
if vm.showUserNameOverlay {
Color.gray.opacity(0.4)
.ignoresSafeArea()
userNameOverlay() // that’s the view I’m talking about
.zIndex(100)
}
}
Подробнее здесь: https://stackoverflow.com/questions/797 ... n-swift-ui