类型 布尔值 对象 输入框 库 native.* 修订版 发行版 2024.3703 关键字 原生文本输入 另请参阅 native.newTextBox()
确定文本框的 object.size 和 object.font 属性所测量的字体大小单位。
如果为 true,则你读或写到文本框属性中的字体大小将使用 Corona 的
如果为 false,则你读或写到文本框属性中的字体大小将使用平台的原生点系统。在这种情况下,Corona 内容缩放不会应用于字体大小。在 iOS 上,这将使用 Apple 的点系统。在 Android 上,这是以 DP(设备无关像素)单位设置的。
在文本框创建后,此属性的默认值由 display.setDefault() 和 "isNativeTextBoxFontSizeScaled" 键确定,其默认值为 true。
-- Create a text object
local textSettings =
{
text = "This is my text label.",
x = display.contentCenterX,
y = 100,
width = display.contentWidth - 20,
font = native.systemFont,
fontSize = 20,
}
local textLabel = display.newText( textSettings )
-- Create a native text box using the same font size as the above text object
local textBox = native.newTextBox( display.contentCenterX, 200, display.contentWidth-20, 120 )
textBox.isFontSizeScaled = true -- Make the text box use the same font units as the text object
textBox.size = textLabel.size
-- Print the text box's font size measured in Corona's content-scaled units
print( "Text Box Font Size (Corona Units) = " .. tostring( textBox.size ) )
-- Print the text box's font size measured in the platform's native units
textBox.isFontSizeScaled = false
print( "Text Box Font Size (Native Units) = " .. tostring( textBox.size ) )