object.hasBackground

类型 布尔
对象 文本框
native.*
版本 版本 2024.3703
关键字 文本输入、文本框、原生文本
另请参见 native.newTextBox()
native.newTextField()

概述

控制文本框是否具有不透明背景。默认值是 true(不透明)。

陷阱

此属性在 Win32 桌面应用程序或 Windows 的 Corona 模拟器中不受支持。

示例

-- Draw red background
local rect = display.newRect( 0, 0, 320, 480 )
rect:setFillColor( 1, 0, 0 )

-- Text box with transparent background
local textBox = native.newTextBox( 160, 240, 280, 140 )
textBox.font = native.newFont( "Helvetica-Bold", 16 )
textBox:setTextColor( 0.8, 0.8, 0.8 )
textBox.hasBackground = false
textBox.text = "Hello, world!"