如何在tabBar上显示叠加屏幕?

时间:2013-12-10 06:16:21

标签: lua corona

main.lua中,我创建了带有三个按钮和三个屏幕的tabBar( screen1,screen2,screen3

  1. screen1 中,我想显示模态叠加

    local options = {
            effect = "fromBottom",
            time = 400,
            isModal = true,
        }
    
    storyboard.showOverlay( "get", options )
    
  2. 一切正常,但我想在tabBar上显示叠加层(就像xCode中的模态视图一样)。 我该怎么办?

    1. 在一个案例中,我应该从 screen1

      “转到” screen3
      storyboard.gotoScene( "screen3")
      
    2. 它有效,但选中的tabButton仍然是 tabButton1 (带 screen1

      如何以编程方式选择tabButton?

      以下是在main.lua中创建 tabBar 的代码:

      -- Create buttons table for the tab bar
      local tabButtons = {
          {
              width = 32, height = 32,
              defaultFile = "assets/tabIcon.png", overFile = "assets/tabIcon-down.png",
              label = translations["tab1"][language],
              onPress = function() storyboard.gotoScene( "screen1" ); end,
              selected = true
          },
          {
              width = 32, height = 32,
              defaultFile = "assets/tabIcon.png", overFile = "assets/tabIcon-down.png",
              label = translations["tab2"][language],
              onPress = function() storyboard.gotoScene( "screen2" ); end,
          },
          {
              width = 32, height = 32,
              defaultFile = "assets/tabIcon.png", overFile = "assets/tabIcon-down.png",
              label = translations["tab3"][language],
              onPress = function() storyboard.gotoScene( "screen3" ); end,
          }
      }
      --Create a tab-bar and place it at the bottom of the screen
      local tabBar = widget.newTabBar {
          top = display.contentHeight - 50,
          height = 50,
          width = display.contentWidth,
          --backgroundFile = "assets/tabbar.png",
          tabSelectedFrameWidth = 1,
          tabSelectedFrameHeight = 49,
          buttons = tabButtons 
      }
      storyboard.gotoScene( "screen1", "crossFade", 200 )
      

2 个答案:

答案 0 :(得分:0)

我认为你不能在标签栏上显示任何图像,因为它是一个原生对象。我可以看到它可能工作的唯一方法是将图像和tabBar插入2组。然后将display.newGroup()放在另一个上。我甚至认为这不会奏效,但请试一试。

答案 1 :(得分:0)

实际上在Corona的情况下,如果你使用的是widget.newTabBar(),它们就是Corona显示对象。我认为您遇到的问题是故事板对象位于任何不受故事板管理的对象之下。

由于您的tabBar通常不受故事板管理,因此它将位于任何故事板场景的顶部,包括叠加层。为了使你的工作按照你想要的方式工作,你可能需要创建一个场景(称之为menu.lua或tabbar.lua),在它的createScene函数中创建tabBar,并确保将tabBar添加到场景的视图中。现在该场景由故事板管理,您的叠加层现在可以覆盖它。

相关问题