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
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.
CodePudding user response:
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.