【问题标题】:Tab item spacing in SwiftuiSwiftui 中的选项卡项间距
【发布时间】:2021-05-08 20:23:39
【问题描述】:

尝试 tabItem 选项并遇到问题....我在分隔选项卡视图上的元素时遇到了一些问题。在第一个元素之前的左侧有一个超长的缩进。(见图)我遇到了一个解决方案,但我不确定将它放在哪里,或者在 SwiftUI 中是否有更好的东西:(tabBar.itemPositioning = .填)

我们将不胜感激。 谢谢

Screenshot

==============

struct ContentView: View {
    @State var selected = 0
    var body: some View {
        TabView (selection: $selected){
            mainscreen()
            DayEntry().tabItem ({
                Image(systemName: "calendar.circle")
                Text("Home")
            }).tag(0)
           mainscreen()
                .tabItem ({
                    Image(systemName: "quote.bubble")
                    Text("Quote")
                }).tag(1)
            DayEntryVStacks()
                 .tabItem ({
                     Image(systemName: "gear")
                     Text("Settings")
                 }).tag(2)
            DayEntryVStacks()
                 .tabItem ({
                     Image(systemName: "calendar.badge.plus")
                     Text("Month")
                 }).tag(3)
        } .accentColor(.red)
        
        
   //     tabBar.itemPositioning = .fill

    }
}

【问题讨论】:

    标签: swiftui tabitem


    【解决方案1】:

    第一个元素之前的左侧有一个超长的缩进

    这不是您没有为主屏幕添加选项卡项的缩进,因此它在第一个视图中显示为空白。因此,要解决此问题,您必须添加选项卡项:

        TabView (selection: $selected){
            mainscreen()
                            // << here !!
            DayEntry().tabItem ({
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-10-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-07-12
      • 2015-12-11
      相关资源
      最近更新 更多