object.height

类型 数字
对象 DisplayObject
display.*
版本 Release 2024.3703
关键字 对象、高度、大小
参见 object.contentHeight
object.width

概述

检索或更改显示对象的高度。对于 text 对象,该属性可用于获取(但不能设置)高度。

对于图像,返回的值是原始位图高度,包括所有透明区域。

需注意

此值不受 object:scale()object.yScale 影响。同样,此值也不受对象旋转影响。

示例

local rect1 = display.newRect( 100, 100, 50, 50 )
rect1:setFillColor( 0.5, 0, 1 )
 
local rect2 = display.newRect( 100, 100, 50, 50 )
rect2:setFillColor( 1, 0, 0 )
rect2.y = rect1.y + rect1.height+10

local rect3 = display.newRect( 150, 75, 50, 50 )
rect3:setFillColor( 0, 0.5, 1 )
rect3.anchorY = 0

transition.to( rect3, { time=2000, height=110 } )