object:resizeFontToFitHeight()

Type Function
Object TextField
Library native.*
Return value none
Revision 2017.3145
Keywords resizeFontToFitHeight, native text input
See also object:resizeHeightToFitFont()
native.newTextField()

Overview

Changes the font size to "best fit" the current height of the text field. This will automatically occur when you first create a text field via the native.newTextField() function.

Syntax

object:resizeFontToFitHeight()

Example

-- Create the text field
-- When a text field is created, it will auto-size its font to best fit the field height
local textField = native.newTextField( 160, 240, 280, 40 )
textField.text = "Hello World"

-- Change the height of the text field
textField.height = 60
-- Resize the font to best fit the text field's new height
textField:resizeFontToFitHeight()