Aprenda
Classe do mecanismo
StyleRule

*Este conteúdo é traduzido por IA (Beta) e pode conter erros. Para ver a página em inglês, clique aqui.


Resumo
Métodos
GetProperty(name: string):Variant
SetDefaultPropertyTransition(transitionParams: Variant):()
SetProperties(styleProperties: Dictionary):()
SetProperty(name: string,value: Variant):()
SetPropertyTransition(property: string,transitionParams: Variant):()
Membros herdados

Referência API
Propriedades
Priority
Ler Parallel
Recursos: UI
StyleRule.Priority:number

Selector
Ler Parallel
Recursos: UI
StyleRule.Selector:string
Amostras de código
Seletor de Classe de UI
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local screenGui = script.Parent
local coreSheet = Instance.new("StyleSheet")
coreSheet.Parent = ReplicatedStorage
local styleLink = Instance.new("StyleLink")
styleLink.StyleSheet = coreSheet
styleLink.Parent = screenGui
local rule = Instance.new("StyleRule")
rule.Parent = coreSheet
-- Seletor de classe
rule.Selector = "TextButton"
-- Definir propriedades da regra
rule:SetProperties({
["BackgroundColor3"] = Color3.fromHex("335FFF"),
["TextColor3"] = Color3.fromHex("E1E1E1"),
["Size"] = UDim2.new(0.15, 0, 0, 40),
["BorderSizePixel"] = 0,
})
local button = Instance.new("TextButton")
button.Text = "Menu Principal"
button.Parent = screenGui
Seletor de Tag de UI
local CollectionService = game:GetService("CollectionService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local screenGui = script.Parent
local coreSheet = Instance.new("StyleSheet")
coreSheet.Parent = ReplicatedStorage
local styleLink = Instance.new("StyleLink")
styleLink.StyleSheet = coreSheet
styleLink.Parent = screenGui
local rule = Instance.new("StyleRule")
rule.Parent = coreSheet
-- Seletor de tag
rule.Selector = ".ButtonPrimary"
-- Definir propriedades da regra
rule:SetProperties({
["BackgroundColor3"] = Color3.fromHex("FF0099"),
["TextColor3"] = Color3.fromHex("E1E1E1"),
["Size"] = UDim2.new(0.15, 0, 0, 40),
["BorderSizePixel"] = 0,
})
local button = Instance.new("TextButton")
button.Text = "Menu Principal"
button.Parent = screenGui
-- Aplicar tag ao botão
CollectionService:AddTag(button, "ButtonPrimary")
Seletor de Modificador de UI
local CollectionService = game:GetService("CollectionService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local screenGui = script.Parent
local coreSheet = Instance.new("StyleSheet")
coreSheet.Parent = ReplicatedStorage
local styleLink = Instance.new("StyleLink")
styleLink.StyleSheet = coreSheet
styleLink.Parent = screenGui
local rule = Instance.new("StyleRule")
rule.Parent = coreSheet
-- Seletor de componente de UI
rule.Selector = "Frame.RoundedCorner20::UICorner"
-- Definir propriedade da regra
rule:SetProperty("CornerRadius", UDim.new(0, 20))
-- Criar frame
local frame = Instance.new("Frame")
frame.Size = UDim2.new(0.4, 0, 0.2, 0)
frame.Parent = screenGui
-- Aplicar tag ao frame
CollectionService:AddTag(frame, "RoundedCorner20")
Selecionador de Consulta de Estilo de UI
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local screenGui = script.Parent
local coreSheet = Instance.new("StyleSheet")
coreSheet.Parent = ReplicatedStorage
local styleLink = Instance.new("StyleLink")
styleLink.StyleSheet = coreSheet
styleLink.Parent = screenGui
local smallRule = Instance.new("StyleRule")
smallRule.Parent = coreSheet
local mediumRule = Instance.new("StyleRule")
mediumRule.Parent = coreSheet
-- Declare seletores de consulta de estilo
smallRule.Selector = "@Small"
mediumRule.Selector = "@Medium"
-- Defina propriedades da regra
smallRule:SetProperties({
["BackgroundColor3"] = Color3.fromHex("FF0099"),
["Text"] = "Recipiente Pequeno",
["TextColor3"] = Color3.fromHex("E1E1E1"),
["TextSize"] = 12,
})
mediumRule:SetProperties({
["BackgroundColor3"] = Color3.fromHex("F0F0F0"),
["Text"] = "Recipiente Médio",
["TextColor3"] = Color3.fromHex("0022FC"),
["TextSize"] = 24,
})
local button = Instance.new("TextButton")
button.Text = "Menu Principal"
button.Parent = screenGui
button.Size = UDim2.fromScale(0.5, 0.2)
-- Crie consultas de estilo com nomes correspondentes aos selecionadores de regras de estilo
local mediumSQ = Instance.new("StyleQuery")
mediumSQ.Parent = button
mediumSQ.Name = "Medium"
mediumSQ:SetConditions({
["MinSize"] = Vector2.new(200, 0),
})
local smallSQ = Instance.new("StyleQuery")
smallSQ.Parent = button
smallSQ.Name = "Small"
smallSQ:SetConditions({
["MaxSize"] = Vector2.new(200, math.huge),
["MinSize"] = Vector2.new(0, 0),
})

SelectorError
Somente leitura
Não replicado
Ler Parallel
Recursos: UI
StyleRule.SelectorError:string

Métodos
GetDefaultPropertyTransition
Recursos: UI
StyleRule:GetDefaultPropertyTransition():Variant
Devolução
Variant

GetProperties
Recursos: UI
StyleRule:GetProperties():Dictionary
Devolução

GetProperty
Recursos: UI
StyleRule:GetProperty(name:string):Variant
Parâmetros
name:string
Devolução
Variant

GetPropertyTransitions
Recursos: UI
StyleRule:GetPropertyTransitions():Dictionary
Devolução
Amostras de código
GetPropertyTransitions()
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local coreSheet = ReplicatedStorage:FindFirstChild("CoreSheet")
-- Obter referência à regra de estilo
local frameRule = coreSheet.Frame
-- Definir algumas transições
frameRule:SetPropertyTransition("BackgroundColor3", TweenInfo.new(1, Enum.EasingStyle.Linear))
frameRule:SetPropertyTransition("BackgroundTransparency", "$DefaultTransition")
local transitions = frameRule:GetPropertyTransitions()
print(transitions)

SetDefaultPropertyTransition
Recursos: UI
StyleRule:SetDefaultPropertyTransition(transitionParams:Variant):()
Parâmetros
transitionParams:Variant
Devolução
()

SetProperties
Recursos: UI
StyleRule:SetProperties(styleProperties:Dictionary):()
Parâmetros
styleProperties:Dictionary
Devolução
()

SetProperty
Recursos: UI
StyleRule:SetProperty(
name:string, value:Variant
):()
Parâmetros
name:string
value:Variant
Devolução
()

SetPropertyTransition
Recursos: UI
StyleRule:SetPropertyTransition(
property:string, transitionParams:Variant
):()
Parâmetros
property:string
transitionParams:Variant
Devolução
()
Amostras de código
SetPropertyTransition()
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local coreSheet = ReplicatedStorage:FindFirstChild("CoreSheet")
-- Obter referência à regra de estilo
local frameRule = coreSheet.Frame
-- Definir uma transição linear de 1 segundo na BackgroundColor3
frameRule:SetPropertyTransition("BackgroundColor3", TweenInfo.new(
1, -- Tempo
Enum.EasingStyle.Linear -- Estilo de Easing
))
-- Remover a transição
frameRule:SetPropertyTransition("BackgroundColor3", nil)
SetPropertyTransition() Usando Tokens
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local coreSheet = ReplicatedStorage:FindFirstChild("CoreSheet")
local tokensSheet = ReplicatedStorage:FindFirstChild("Tokens")
-- Defina tokens (atributos) na folha de tokens
tokensSheet:SetAttribute("LinearTransition", TweenInfo.new(1, Enum.EasingStyle.Linear))
-- Obtenha referência à regra de estilo
local frameRule = coreSheet.Frame
frameRule:SetPropertyTransition("BackgroundColor3", "$LinearTransition")

SetPropertyTransitions
Recursos: UI
StyleRule:SetPropertyTransitions(properties:Dictionary):()
Parâmetros
properties:Dictionary
Devolução
()
Amostras de código
DefinirTransiçõesDePropriedade()
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local coreSheet = ReplicatedStorage:FindFirstChild("CoreSheet")
-- Obter referência à regra de estilo
local frameRule = coreSheet.Frame
-- Define transições para duas propriedades ao mesmo tempo
frameRule:SetPropertyTransitions({
["BackgroundColor3"] = TweenInfo.new(1, Enum.EasingStyle.Linear),
["BackgroundTransparency"] = TweenInfo.new(0.25, Enum.EasingStyle.Quad, Enum.EasingDirection.Out),
})
-- Remove todas as transições
frameRule:SetPropertyTransitions({})
SetPropertyTransitions() Usando Tokens
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local coreSheet = ReplicatedStorage:FindFirstChild("CoreSheet")
local tokenSheet = ReplicatedStorage:FindFirstChild("Tokens")
-- Definir tokens (atributos) na planilha de tokens
tokenSheet:SetAttribute("LinearTransition", TweenInfo.new(1, Enum.EasingStyle.Linear))
tokenSheet:SetAttribute("QuadTransition", TweenInfo.new(0.25, Enum.EasingStyle.Quad))
-- Obter referência à regra de estilo
local frameRule = coreSheet.Frame
-- Definir transições para múltiplas propriedades de uma vez
frameRule:SetPropertyTransitions({
["BackgroundColor3"] = "$LinearTransition",
["BackgroundTransparency"] = "$QuadTransition",
})

©2026 Roblox Corporation, Roblox, o logotipo Roblox e Powering Imagination estão entre nossas marcas registradas e não registradas nos EUA e em outros países.