How to put image and bottom text together in UIButton?

I want to put a centered image and bottom centered text in a UIButton.

How can i do this?

Thanks in advance.

+3
source share
3 answers

Ok, figure out how to do this. Using methods:

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

If you have any specific solution, with UIButton with the image and text below. I made an extended class from UIButton to simplify it:

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

You only need to use the UIButtonBox in Interface Builder and it will automatically display the text below.

+3
source

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

: , , ,

. , .

0

Source: https://habr.com/ru/post/1736898/


All Articles