學習
引擎類別
ImageLabel

*此內容是使用 AI(Beta 測試版)翻譯,可能含有錯誤。若要以英文檢視此頁面,請按一下這裡



API 參考
屬性
Image
平行讀取
功能: UI
ImageLabel.Image:ContentId

ImageColor3
平行讀取
功能: UI
ImageLabel.ImageColor3:Color3

ImageContent
平行讀取
功能: UI
ImageLabel.ImageContent:Content

ImageRectOffset
平行讀取
功能: UI
ImageLabel.ImageRectOffset:Vector2

ImageRectSize
平行讀取
功能: UI
ImageLabel.ImageRectSize:Vector2

ImageTransparency
平行讀取
功能: UI
ImageLabel.ImageTransparency:number
範例程式碼
振盪圖像透明度
local RunService = game:GetService("RunService")
local imageLabel =
script.Parent
local function onRenderStep()
-- 振盪圖像透明度從 0 到 1 使用正弦波
imageLabel.ImageTransparency = math.sin(workspace.DistributedGameTime
* math.pi) * 0.5 + 0.5
end
RunService.RenderStepped:Connect(onRenderStep)

IsLoaded
唯讀
未複製
平行讀取
功能: UI
ImageLabel.IsLoaded:boolean
範例程式碼
圖像加載時間
local imageLabel = script.Parent
local startTime = workspace.DistributedGameTime
-- 等待圖像加載
while not imageLabel.IsLoaded do
task.wait()
end
-- 測量並顯示加載所需的時間
local deltaTime = workspace.DistributedGameTime - startTime
print(("圖像加載時間為 %.3f 秒"):format(deltaTime))

ResampleMode
平行讀取
功能: UI
ImageLabel.ResampleMode:Enum.ResamplerMode

ScaleType
平行讀取
功能: UI
ImageLabel.ScaleType:Enum.ScaleType

SliceCenter
平行讀取
功能: UI
ImageLabel.SliceCenter:Rect

SliceScale
平行讀取
功能: UI
ImageLabel.SliceScale:number

TileSize
平行讀取
功能: UI
ImageLabel.TileSize:UDim2
範例程式碼
圖像縮放模式示範
local imageLabel = script.Parent
-- 將源圖像設置為 64x64 鎖頭圖像
imageLabel.Image = "rbxassetid://284402752"
imageLabel.BackgroundTransparency = 0
imageLabel.BackgroundColor3 = Color3.new(1, 1, 1) -- 白色
imageLabel.ImageColor3 = Color3.new(0, 0, 0) -- 黑色
local function resizeInACircle()
for theta = 0, 2, 0.02 do
imageLabel.Size =
UDim2.new(0, 100 + math.cos(theta * 2 * math.pi) * 50, 0, 100 + math.sin(theta * 2 * math.pi) * 50)
task.wait()
end
end
while true do
-- 拉伸只是簡單地將源圖像拉伸以適應
-- UI 元素的空間
imageLabel.ScaleType = Enum.ScaleType.Stretch
resizeInACircle()
-- 平鋪將多次渲染源圖像
-- 以填滿 UI 元素的空間
imageLabel.ScaleType = Enum.ScaleType.Tile
imageLabel.TileSize = UDim2.new(0, 64, 0, 64)
resizeInACircle()
-- 切片將圖像變成九切片 UI。
imageLabel.ScaleType = Enum.ScaleType.Slice
imageLabel.SliceCenter = Rect.new(30, 30, 34, 34)
resizeInACircle()
end

©2026 Roblox Corporation、Roblox、Roblox 標誌及 Powering Imagination 是我們在美國及其他國家地區的部分註冊與未註冊商標。