Http://blog.csdn.net/yanxiaoqing/article/details/7230660
By default, all the effects that are not set are centered and the button is 150*150.
After using the following settings:
[Self settitleedgeinsets: uiedgeinsetsmake (0.0,-backgroundimag. Size. Width, 0.0, 0.0)];
[Self setimageedgeinsets: uiedgeinsetsmake (0.0, 0.0, 0.0,
-Self. titlelabel. bounds. Size. width)];
If you want to place the title on the top of the image, move the position up to 80 relative to the image.
[Self settitleedgeinsets: uiedgeinsetsmake (-80.0,-backgroundimag. Size. Width, 0.0, 0.0)];
[Self setimageedgeinsets: uiedgeinsetsmake (0.0, 0.0, 0.0,
-Self. titlelabel. bounds. Size. width)];
The effect is as follows:
To sum up, if you set a title or image position in the button separately, uiedgeinsets is calculated relative to the frame of the button (top, left, bottom, right ,), if the problem is described just now, the title is set relative to the frame of the image, and the position of the image is set relative to the location of the titel.
Over!