View Single Post
04/04/14, 11:38 AM   #5
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
AddOn Author - Click to view addons
Join Date: Feb 2014
Posts: 648
frame:SetAnchor(pointOnFrame, relativeToThisFrame, pointOnThatOtherFrame, offsetX, offsetY)

Offsets increase in a positive direction to the right (for X) and down (for Y). They increase in a negative direction to the left (for X) and up (for Y).

So... If you want to anchor your MyAddonFrame to the main screen (GuiRoot), in the top-left corner, but out from each side about 10 pixels, you'd do this:
Lua Code:
  1. MyAddonFrame:SetAnchor(TOPLEFT, GuiRoot, TOPLEFT, 10, 10)

If you want to anchor the left side of your MyAddonFrame2 to the right side of your MyAddonFrame1, you'd do this:
Lua Code:
  1. MyAddonFrame2:SetAnchor(LEFT, MyAddonFrame1, RIGHT, 0, 0)

If you want to make your MyAddonBG texture fill your whole MyAddonFrame (anchoring to all corners), then you can do this:
Lua Code:
  1. MyAddonBG:SetAnchorFill(MyAdonFrame)

One last example: if you want your MyAddonFrame to spread across the bottom of the screen, without having to worry about figuring out how big the users screen is (resolution/width), then you can do this:
Lua Code:
  1. MyAddonFrame:SetAnchor(BOTTOMLEFT, GuiRoot, BOTTOMLEFT, 0, 0)
  2. MyAddonFrame:SetAnchor(BOTTOMRIGHT, GuiRoot, BOTTOMRIGHT, 0, 0)
  3. MyAddonFrame:SetHeight(100)
  Reply With Quote