简体   繁体   中英

How can i move a Horizontal Stack upwards in Swift UI

I am new to Swift UI a small help will be appreciated a lot.

Right now my app design looks as shown below in image

this is image please see it

the code for my app is as shown below

var body: some View {
    VStack(){
        ZStack {
            VStack(){
                
                HStack(){
                    Text("All Savings Bank Accounts")
                        .font(.title2)
                        .frame( alignment: .top)
                    Button("+") {
                        isSavingsFundsAlertsPresented = true
                    }.font(.title2)
                    .frame(alignment: .top)
                }
                Spacer()
                List(allBankAccountFunds){
                    aRow in TableRowSavingsAccount(Account: aRow)
                }
            }
            AlertView(isShown: $isSavingsFundsAlertsPresented, Name: $SavingAccountName, Amount: $SavingAccountAmount, title: "Add Savings Account", placeholder: "Name of Account", buttonText: "Add Account") {
                if(SavingAccountName != ""){
                    let newAccount = SavingsAccount(context: context);
                    newAccount.accountName = SavingAccountName;
                    newAccount.accountBalance = Double(SavingAccountAmount) ?? 0;
                    
                    do{
                        try context.save()
                    }catch{
                        print(error)
                    }
                }
                    //after the alert has ended closure of on Done function
            }
        }
        ZStack {
            VStack{

even though i included spacer() in between HStack and List, still Hstack is way low,

All i want to achieve is to somehow reduce the space between Text("All savings bank account") and top notch.

if i try to ignoreallsafeEdges() the Hstack completely disappears.

I am new to swiftUI , any help will be highly appreciated.

If you present this View inside NavigationView , default NavigationBar appears.

If you add

.navigationBarTitle("")
.navigationBarHidden(true)

to VStack which below body , NavigationBar will be hidden.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM