Ghi chú phát hành
Học
Lớp công cụ
StyleRule

*Nội dung này được dịch bằng AI (Beta) và có thể có lỗi. Để xem trang này bằng tiếng Anh, hãy nhấp vào đây.


Tóm Tắt
Phương Pháp
GetProperty(name: string):Variant
SetDefaultPropertyTransition(transitionParams: Variant):()
SetProperties(styleProperties: Dictionary):()
SetProperty(name: string,value: Variant):()
SetPropertyTransition(property: string,transitionParams: Variant):()
Thành viên kế thừa

Tài Liệu Tham Khảo API
Thuộc Tính
Priority
Đọc Song Song
Các khả năng: UI
StyleRule.Priority:number

Selector
Đọc Song Song
Các khả năng: UI
StyleRule.Selector:string
Mẫu mã
Trình chọn lớp 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
-- Trình chọn lớp
rule.Selector = "TextButton"
-- Đặt thuộc tính quy tắc
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 Chính"
button.Parent = screenGui
Trình chọn thẻ 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
-- Trình chọn thẻ
rule.Selector = ".ButtonPrimary"
-- Đặt thuộc tính quy tắc
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 = "Thực đơn chính"
button.Parent = screenGui
-- Áp dụng thẻ cho nút
CollectionService:AddTag(button, "ButtonPrimary")
Bộ Chọn Bộ Điều Chỉnh 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
-- Bộ chọn thành phần UI
rule.Selector = "Frame.RoundedCorner20::UICorner"
-- Đặt thuộc tính quy tắc
rule:SetProperty("CornerRadius", UDim.new(0, 20))
-- Tạo khung
local frame = Instance.new("Frame")
frame.Size = UDim2.new(0.4, 0, 0.2, 0)
frame.Parent = screenGui
-- Áp dụng nhãn cho khung
CollectionService:AddTag(frame, "RoundedCorner20")
Trình chọn truy vấn kiểu 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
-- Khai báo các trình chọn truy vấn kiểu
smallRule.Selector = "@Small"
mediumRule.Selector = "@Medium"
-- Thiết lập thuộc tính quy tắc
smallRule:SetProperties({
["BackgroundColor3"] = Color3.fromHex("FF0099"),
["Text"] = "Thùng chứa Nhỏ",
["TextColor3"] = Color3.fromHex("E1E1E1"),
["TextSize"] = 12,
})
mediumRule:SetProperties({
["BackgroundColor3"] = Color3.fromHex("F0F0F0"),
["Text"] = "Thùng chứa Trung Bình",
["TextColor3"] = Color3.fromHex("0022FC"),
["TextSize"] = 24,
})
local button = Instance.new("TextButton")
button.Text = "Menu Chính"
button.Parent = screenGui
button.Size = UDim2.fromScale(0.5, 0.2)
-- Tạo các truy vấn kiểu với tên phù hợp với các trình chọn quy tắc kiểu
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
Chỉ Đọc
Không Sao Chép
Đọc Song Song
Các khả năng: UI
StyleRule.SelectorError:string

Phương Pháp
GetDefaultPropertyTransition
Các khả năng: UI
StyleRule:GetDefaultPropertyTransition():Variant
Lợi Nhuận
Variant

GetProperties
Các khả năng: UI
StyleRule:GetProperties():Dictionary
Lợi Nhuận

GetProperty
Các khả năng: UI
StyleRule:GetProperty(name:string):Variant
Tham Số
name:string
Lợi Nhuận
Variant

GetPropertyTransitions
Các khả năng: UI
StyleRule:GetPropertyTransitions():Dictionary
Lợi Nhuận
Mẫu mã
GetPropertyTransitions()
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local coreSheet = ReplicatedStorage:FindFirstChild("CoreSheet")
-- Lấy tham chiếu đến quy tắc kiểu
local frameRule = coreSheet.Frame
-- Đặt một số chuyển tiếp
frameRule:SetPropertyTransition("BackgroundColor3", TweenInfo.new(1, Enum.EasingStyle.Linear))
frameRule:SetPropertyTransition("BackgroundTransparency", "$DefaultTransition")
local transitions = frameRule:GetPropertyTransitions()
print(transitions)

SetDefaultPropertyTransition
Các khả năng: UI
StyleRule:SetDefaultPropertyTransition(transitionParams:Variant):()
Tham Số
transitionParams:Variant
Lợi Nhuận
()

SetProperties
Các khả năng: UI
StyleRule:SetProperties(styleProperties:Dictionary):()
Tham Số
styleProperties:Dictionary
Lợi Nhuận
()

SetProperty
Các khả năng: UI
StyleRule:SetProperty(
name:string, value:Variant
):()
Tham Số
name:string
value:Variant
Lợi Nhuận
()

SetPropertyTransition
Các khả năng: UI
StyleRule:SetPropertyTransition(
property:string, transitionParams:Variant
):()
Tham Số
property:string
transitionParams:Variant
Lợi Nhuận
()
Mẫu mã
SetPropertyTransition()
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local coreSheet = ReplicatedStorage:FindFirstChild("CoreSheet")
-- Lấy tham chiếu đến quy tắc kiểu
local frameRule = coreSheet.Frame
-- Đặt chuyển tiếp 1 giây với Linear trên BackgroundColor3
frameRule:SetPropertyTransition("BackgroundColor3", TweenInfo.new(
1, -- Thời gian
Enum.EasingStyle.Linear -- EasingStyle
))
-- Xóa chuyển tiếp
frameRule:SetPropertyTransition("BackgroundColor3", nil)
SetPropertyTransition() Sử dụng Tokens
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local coreSheet = ReplicatedStorage:FindFirstChild("CoreSheet")
local tokensSheet = ReplicatedStorage:FindFirstChild("Tokens")
-- Đặt tokens (thuộc tính) trên bảng tokens
tokensSheet:SetAttribute("LinearTransition", TweenInfo.new(1, Enum.EasingStyle.Linear))
-- Lấy tham chiếu đến quy tắc kiểu
local frameRule = coreSheet.Frame
frameRule:SetPropertyTransition("BackgroundColor3", "$LinearTransition")

SetPropertyTransitions
Các khả năng: UI
StyleRule:SetPropertyTransitions(properties:Dictionary):()
Tham Số
properties:Dictionary
Lợi Nhuận
()
Mẫu mã
SetPropertyTransitions()
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local coreSheet = ReplicatedStorage:FindFirstChild("CoreSheet")
-- Lấy tham chiếu đến quy tắc phong cách
local frameRule = coreSheet.Frame
-- Đặt chuyển tiếp cho hai thuộc tính cùng một lúc
frameRule:SetPropertyTransitions({
["BackgroundColor3"] = TweenInfo.new(1, Enum.EasingStyle.Linear),
["BackgroundTransparency"] = TweenInfo.new(0.25, Enum.EasingStyle.Quad, Enum.EasingDirection.Out),
})
-- Xóa tất cả chuyển tiếp
frameRule:SetPropertyTransitions({})
SetPropertyTransitions() Sử dụng Mã Thông Báo
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local coreSheet = ReplicatedStorage:FindFirstChild("CoreSheet")
local tokenSheet = ReplicatedStorage:FindFirstChild("Tokens")
-- Đặt mã thông báo (thuộc tính) trên bảng mã thông báo
tokenSheet:SetAttribute("LinearTransition", TweenInfo.new(1, Enum.EasingStyle.Linear))
tokenSheet:SetAttribute("QuadTransition", TweenInfo.new(0.25, Enum.EasingStyle.Quad))
-- Lấy tham chiếu đến quy tắc kiểu
local frameRule = coreSheet.Frame
-- Đặt chuyển tiếp cho nhiều thuộc tính cùng một lúc
frameRule:SetPropertyTransitions({
["BackgroundColor3"] = "$LinearTransition",
["BackgroundTransparency"] = "$QuadTransition",
})

©2026 Roblox Corporation. Roblox, logo Roblox và Powering Imagination là các nhãn hiệu đã đăng ký và chưa đăng ký của chúng tôi tại Hoa Kỳ và các quốc gia khác.