开发者

How to put an image and a bottom text together in a UIButton?

I want to put an centered image and a bottom centered text in 开发者_C百科a UIButton.

How I can do that?

Thanks in advance.


Ok, figure out how. Using the methods:

    [button1 setTitleEdgeInsets:UIEdgeInsetsMake(30.0, 0.0, 0.0, 0.0)];
    [button1 setImageEdgeInsets:UIEdgeInsetsMake(-10.0, 29.0, 0.0, 0.0)];


If you what a specific solution, with a UIButton with an Image and a Text below. I made a Extended Class from UIButton to make it easier:

https://gist.github.com/jalopezsuarez/2c8f430636d89a58099b

You only need to use UIButtonBox in Interface Builder and it will layout automatically the text bellow the image.


Try this

[btn setTitleEdgeInsets:UIEdgeInsetsMake(btn.frame.size.height - 20, 1, 1, 1)];

arguments: top, left, bottom, right

Set the frame first. Also reduce the font size to fit in.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜