Ios 自定义选项卡栏快捷界面
我正在学习新知识。我创建了一个选项卡栏,但当键盘打开时,选项卡栏会随着键盘一起上升。 我怎样才能修好它。你能帮助我吗? 我想把标签条固定在底部。 或者有什么东西可以把键盘放到页面的顶部? 因为我不知道在哪里修复它,我不得不扔掉所有的代码Ios 自定义选项卡栏快捷界面,ios,swift,swiftui,Ios,Swift,Swiftui,我正在学习新知识。我创建了一个选项卡栏,但当键盘打开时,选项卡栏会随着键盘一起上升。 我怎样才能修好它。你能帮助我吗? 我想把标签条固定在底部。 或者有什么东西可以把键盘放到页面的顶部? 因为我不知道在哪里修复它,我不得不扔掉所有的代码 struct ContentView: View { @State var selected = 0 var body: some View { VStack{ if self.se
struct ContentView: View {
@State var selected = 0
var body: some View {
VStack{
if self.selected == 0{
Color.blue
}
else if self.selected == 1{
Color.red
}
else if self.selected == 2{
Color.pink
}
else if self.selected == 3{
Color.green
}
else if self.selected == 4{
Color.yellow
}
Spacer()
ZStack(alignment: .top){
BottomBar(selected: self.$selected)
.padding()
.padding(.horizontal, 22)
.background(CurvedShape())
Button(action: {
self.selected = 4
}) {
Image(systemName:"heart.fill").renderingMode(.original).padding(18)
}.background(Color.yellow)
.clipShape(Circle())
.offset(y: -32)
.shadow(radius: 5)
}
}.background(Color("Color").edgesIgnoringSafeArea(.top))
}
}
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
ContentView()
}
}
struct CurvedShape : View {
var body : some View{
Path{path in
path.move(to: CGPoint(x: 0, y: 0))
path.addLine(to: CGPoint(x: UIScreen.main.bounds.width, y: 0))
path.addLine(to: CGPoint(x: UIScreen.main.bounds.width, y: 55))
path.addArc(center: CGPoint(x: UIScreen.main.bounds.width / 2, y: 55),
radius: 30, startAngle: .zero, endAngle: .init(degrees: 180), clockwise: true)
path.addLine(to: CGPoint(x: 0, y: 55))
}.fill(Color.white)
.rotationEffect(.init(degrees: 180))
}
}
struct BottomBar : View {
@Binding var selected : Int
var body : some View{
HStack{
Button(action: {
self.selected = 0
}) {
Image(systemName:"lasso")
}.foregroundColor(self.selected == 0 ? .black : .gray)
Spacer(minLength: 12)
Button(action: {
self.selected = 1
}) {
Image(systemName: "trash")
}.foregroundColor(self.selected == 1 ? .black : .gray)
Spacer().frame(width: 120)
Button(action: {
self.selected = 2
}) {
Image(systemName:"person")
}.foregroundColor(self.selected == 2 ? .black : .gray)
.offset(x: -10)
Spacer(minLength: 12)
Button(action: {
self.selected = 3
}) {
Image(systemName: "pencil")
}.foregroundColor(self.selected == 3 ? .black : .gray)
}
}
}
设置
到内容视图。我想在页面之间提供一种过渡效果,您有任何相关信息吗?@Raja Kishan
.ignoresSafeArea(.keyboard)