StyleRule

Mostrar obsoleto

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

Define propriedades de estilo que substituem propriedades nas instâncias afetadas pela propriedade Selector .

Resumo

Propriedades

  • Ler Parallel

    Um número que determina como as propriedades do StyleRule se aplicam em relação às mesmas propriedades em outro StyleRules .Os valores de prioridade mais altos têm precedência sobre os mais baixos.

  • Ler Parallel

    Uma string que especifica quais instâncias o StyleRule deve afetar.

  • Somente leitura
    Não replicado
    Ler Parallel

    Uma string de leitura somente que exibe erros da propriedade Selector.

Métodos

Métodos herdados de StyleBase

Métodos

Eventos

Eventos herdados de StyleBase

Eventos

Propriedades

Priority

Ler Parallel

Selector

Ler Parallel

Amostras de código

UI Class Selector

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
-- Class selector
rule.Selector = "TextButton"
-- Set rule properties
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 = "Main Menu"
button.Parent = screenGui
UI Tag Selector

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
-- Tag selector
rule.Selector = ".ButtonPrimary"
-- Set rule properties
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 = "Main Menu"
button.Parent = screenGui
-- Apply tag to button
CollectionService:AddTag(button, "ButtonPrimary")
UI Modifier Selector

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
-- UI component selector
rule.Selector = "Frame.RoundedCorner20::UICorner"
-- Set rule property
rule:SetProperty("CornerRadius", UDim.new(0, 20))
-- Create frame
local frame = Instance.new("Frame")
frame.Size = UDim2.new(0.4, 0, 0.2, 0)
frame.Parent = screenGui
-- Apply tag to frame
CollectionService:AddTag(frame, "RoundedCorner20")

SelectorError

Somente leitura
Não replicado
Ler Parallel

Métodos

GetProperties


Devolução

GetProperty

Variant

Parâmetros

name: string
Valor Padrão: ""

Devolução

Variant

SetProperties

()

Parâmetros

styleProperties: Dictionary
Valor Padrão: ""

Devolução

()

SetProperty

()

Parâmetros

name: string
Valor Padrão: ""
value: Variant
Valor Padrão: ""

Devolução

()

Eventos