类型 功能 对象 文本字段 库 native.* 返回值 无 修订 版本 2024.3703 关键字 resizeHeightToFitFont,本机文本输入 另请参阅 object:resizeFontToFitHeight() native.newTextField()
将文本字段的高度更改为“最适合”当前正在使用的字体大小。
object:resizeHeightToFitFont()
-- 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 text field's font size to the system default textField.size = nil -- Resize the text field's height to best fit the font textField:resizeHeightToFitFont()