object:resizeHeightToFitFont()

类型 功能
对象 文本字段
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()