类型 函数 对象 文本字段 库 native.* 返回值 无 版本 版本 2024.3703 关键字 根据高度调整字体大小、原生文本输入 另请参阅 object:resizeHeightToFitFont() native.newTextField()
将字体大小更改为文本字段当前高度的“最合适”大小。通过 native.newTextField() 函数首次创建文本字段时,将自动发生此操作。
object:resizeFontToFitHeight()
-- 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()