I'm creating a UIImageButton programmatically like so:
var button = NGUITools.AddChild<UIImageButton>(parent);
button.name = "my image button";
button.normalSprite = GuiButtonGroup.NormalSprite;
button.hoverSprite = GuiButtonGroup.NormalSprite; // This is intentional. Setting hoverSprite to NormalSprite disables the hover image, which is what we want.
button.pressedSprite = GuiButtonGroup.PressedSprite;
var sprite = NGUITools.AddSprite(button.gameObject, atlas, GuiButtonGroup.NormalSprite);
sprite.depth = GuiButtonGroup.Depth;
button.target = sprite;
var collider = button.gameObject.AddComponent<BoxCollider>();
collider.size = sprite.transform.localScale;
However, the sprite's size (it's transform's scale) is (100, 100, 1) until the user mouses over the button, which then properly resizes the sprite to its proper size (the size of the NormalPressed image I'm providing). This is not only a problem because the sprite is distorted (until the mouse over) and because the collider's size is (100, 100, 1) even after the resize, so the button doesn't click properly.
How can I get the ImageButton to resize itself to its sprite's size automatically, before creating my collider?