StyleRule
*เนื้อหานี้แปลโดยใช้ AI (เวอร์ชัน Beta) และอาจมีข้อผิดพลาด หากต้องการดูหน้านี้เป็นภาษาอังกฤษ ให้คลิกที่นี่
กำหนดคุณสมบัติสไตล์ที่เหนือกว่าคุณสมบัติในตัวอย่างที่ได้รับผลกระทบจากคุณสมบัติ Selector โปรปรียา
สรุป
คุณสมบัติ
จํานวนที่กําหนดวิธีที่คุณสมบัติของ StyleRule สามารถใช้เป็นสัดส่วนกับคุณสมบัติเดียวกันในอื่น ๆ StyleRulesค่าลําดับความสําคัญสูงกว่ามีลําดับความสําคัญก่อนค่าลําดับความสําคัญต่ํากว่า
สตริงที่ระบุว่าตัวอย่างใดที่ StyleRule ควรส่งผลกระทบต่อ
สตริงอ่านเฉพาะที่แสดงข้อผิดพลาดจากคุณสมบัติ Selector
วิธีการ
คืนสารานุกรมของคู่คีย์-ค่าที่อธิบายคุณสมบัติของ StyleRule
คืนค่าของคุณสมบัติเฉพาะใน StyleRule
ให้คุณประกาศและตั้งค่าคุณสมบัติหลายอย่างของ StyleRule ในครั้งเดียว
วิธีการ
ส่งคืนคอลเลกชันของเกี่ยวข้อง StyleRules
สอดใส่ StyleRule ใหม่ลงในคอลเลกชันของกฎ
คล้ายกับ InsertStyleRule() แต่ให้คุณประกาศและตั้งค่าหลาย StyleRules พร้อมกัน
เหตุการณ์
เหตุการณ์รับทอดมาจากStyleBaseเหตุการณ์
ไฟเมื่อหนึ่งหรือมากกว่า StyleRules ถูกเปลี่ยนโดยเฉพาะใน StyleSheet หรือ StyleRule ที่เชื่อมต่อ
คุณสมบัติ
Priority
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
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")
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")