Last active
January 12, 2022 13:41
-
-
Save Meorawr/1661be13add068bcee532afdda6e309f to your computer and use it in GitHub Desktop.
Rotated FontString
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local Button = CreateFrame("Button", nil, UIParent, "UIPanelButtonTemplate"); | |
Button:SetPoint("CENTER"); | |
Button:SetText("Resistances"); | |
local ButtonFontString = Button:GetFontString(); | |
ButtonFontString:ClearAllPoints(); | |
ButtonFontString:SetPoint("CENTER", -5, -10); | |
-- FontStrings can't be rotated like textures, but you can fake it with | |
-- an animation that either infinitely repeats or just never ends. | |
local AnimationGroup = ButtonFontString:CreateAnimationGroup(); | |
local Rotation = AnimationGroup:CreateAnimation("Rotation"); | |
Rotation:SetDegrees(90); | |
Rotation:SetDuration(0); | |
Rotation:SetEndDelay(math.huge); | |
AnimationGroup:Play(); | |
-- Note that using animations means the logical rect of the fontstring | |
-- thinks it's always horizontal, as you can see via /fstack. | |
-- | |
-- When updating the size of the host button you'll need to swap the | |
-- width and height as below. | |
local width = ButtonFontString:GetHeight() + 20; | |
local height = ButtonFontString:GetWidth() + 40; | |
Button:SetSize(width, height); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment