2015年4月21日 星期二

[Corona SDK] How can we change the size and color of button text?

If we want to add a button, we can use the newButton funtion provided by widget, as the example shown below:
local widget = require( "widget" )
local button1Press = function( event )
 print("button1 pressed")
end

local button1 = widget.newButton
{
 defaultFile = "buttonYellow.png",
 overFile = "buttonYellowOver.png",
 label = "botton 1",     
 onPress = button1Press,
}
defaultFile is to set the default picture,
overFile is to get the picture when use press this button.
The text on button is "botton 1".
However, its size and color are as default.
If we want to change them, we can reference the following codes:
local widget = require( "widget" )
local button1Press = function( event )
  print("button1 pressed")
end

local button1 = widget.newButton
{
  defaultFile = "buttonYellow.png",
  overFile = "buttonYellowOver.png",
  label = "botton 1", 
  font = native.systemFont,
  fontSize = 20,
  emboss = true,
  labelColor = { default = { 0.5, 1, 1 }, over = { 0.5, 0.5, 0.5} },    
  onPress = button1Press,
}

沒有留言:

張貼留言