Post

Replies

Boosts

Views

Activity

Tab bar height changes when switching between the tab
My tab bar has different height when I switch between different tab. At the info tab, the height of the tab view looks pretty normal but at the home page, the tab bar height is abnormal Are there any ways to solve this problem my code block for the main page TabView{ aboutMe() .tabItem(){ Image("ghost") Text("Info") } topSpaceBar() .tabItem(){ Image(systemName: "lifepreserver") Text("Home") } Moments() .tabItem(){ Image(systemName: "square.and.pencil") Text("call") } Messages() .badge(10) .tabItem(){ Image(systemName: "bubble") Text("call") } } when I goes to second tab, the height changes , but the rest of tab works fine NavigationView{ ZStack(alignment:.top){ TabView(selection: self.$currentTab){ Home(type:"lt") .tag(0) .background(.red) Home(type:"pp") .tag(1) .background(.yellow) Home(type:"yl") .tag(2) .background(.blue) Home(type: "kj") .tag(3) .background(.green) Home(type:"ks") .tag(4) .background(.white) } .foregroundColor(.black) TabBarView(currentTab: $currentTab) } .navigationBarHidden(true) }``` TabBarView is mu custom Tab bar
1
0
650
Mar ’24
Why NavigationLink is not same length of the Vstack
NavigationView { VStack{ Spacer() logo() Spacer() Text("电话号码") .frame(maxWidth: .infinity, alignment: .leading) .padding(.bottom, 10) HStack{ CountryPicker(selectedCountry: $selectedCountry) TextField("Phones Number", text: $phoneNumber) .keyboardType(.numberPad) .textFieldStyle(RoundedBorderTextFieldStyle()) } .padding(.bottom, 14) .frame(maxWidth: .infinity, alignment: .leading) Text("验证码") .frame(maxWidth: .infinity, alignment: .leading) .padding(.bottom, 10) TextField("Verification Code", text: $phoneNumber) .keyboardType(.numberPad) .textFieldStyle(RoundedBorderTextFieldStyle()) NavigationLink(destination: login()) { Text("登陆") .foregroundColor(.white) .padding() .background(Color.black) .cornerRadius(10) .frame(maxWidth: .infinity, alignment: .center) .bold() } .buttonStyle(PlainButtonStyle()) .padding(.top,36) Spacer() } .navigationTitle("") .navigationBarItems( trailing: NavigationLink(destination: Text("Second View")) { Text("遇到问题") } // Vstack Line ) .padding() .frame(maxWidth: .infinity) // Navigation Stack } .padding(.vertical, 5) Hi, I'm new to swift ui, I tried to make the Text("登陆") .foregroundColor(.white) .padding() .background(Color.black) .cornerRadius(10) .frame(maxWidth: .infinity, alignment: .center) .bold() } this navigationLink expand the whole width of the Vstack, so I tried to use .frame(maxWidth: infinity) on it but it still doesn't work Can any one helps me on this problem, Thank you
1
0
474
Mar ’24