Getting Started - NavigationControl

Ease your way into the NavigationControl widget.

Check the examples folder to see working examples of a NavigationControl

General Usage

View Object

You give a view to the NavigationControl to display. A view can be one of the following:

  • a Corona display group
  • a Corona display object
  • a dmc-object

View Properties

name type description
.title string used as the text to display at the top of the navigation. _At a minimum, set this property, unless you create your own NavItem
.navItem NavItem used to give additional page information for the NavBar. One is created by default, and uses the page .title or 'unknown'
It is assumed that the view anchor is set at { 0.5, 0 } (top-center).

Simple Navigation Control

This is the example Navigation-Simple. Here we are just using simple shapes from display.newRect() to act as our views.

local dUI = require 'lib.dmc_ui'

local W, H = dUI.WIDTH, dUI.HEIGHT
local H_CENTER, V_CENTER = W*0.5, H*0.5

local navCtrl, view

-- create NavCntrl, position on screen
-- here y=20 is height of iOS status bar

navCtrl = dUI.newNavigationControl()
navCtrl.x, navCtrl.y = H_CENTER, 20

-- create view 1

view = display.newRect( 0, 0, W, H )
view:setFillColor( 0.3, 0.4, 0.5 )
view.anchorX, view.anchorY = 0.5, 0
view.title = 'View 1'
navCtrl:pushView( view )

-- create view 2

timer.performWithDelay( 1000, function()
    view = display.newRect( 0, 0, W, H )
    view:setFillColor( 0.5, 0.6, 0.7 )
    view.anchorX, view.anchorY = 0.5, 0
    view.title = 'View 2'
    navCtrl:pushView( view )
end)

-- create view 3

timer.performWithDelay( 2000, function()
    view = display.newRect( 0, 0, W, H )
    view:setFillColor( 0.7, 0.5, 0.3 )
    view.anchorX, view.anchorY = 0.5, 0
    view.title = 'View 3'
    navCtrl:pushView( view )
end)