1

I have a UIButton in which I want to insert an image that would stretch to the button size. The button property allow it to stretch "down" the included image to fit the button size, but I want to do the opposite : the thing is that my image is small, and I want it to grow if the button is bigger than the image.

How may I do this ?

Rod
  • 52,748
  • 3
  • 38
  • 55
Oliver
  • 23,072
  • 33
  • 138
  • 230

3 Answers3

3

Set the image as the background image of the button.

Nick Weaver
  • 47,228
  • 12
  • 98
  • 108
0

I had same problem and after searching i found a good thread.

How do I scale a UIButton's imageView?

I will suggest you to set background image of button which will solve your problem.

And be careful if you are resizing image programatically it will take time to resize. If you have multiple images and you are resizing programatically do it on different background thread which will protect your main thread and GUI will not hang and set resized image on main thread.

Community
  • 1
  • 1
Vijay Sharma
  • 1,046
  • 9
  • 19
0

you can use property value Aspect Fit or something related to it.

Saboor Awan
  • 1,567
  • 4
  • 24
  • 37
  • No, Aspect Fit won't work right, look [How to good resize UIImage ](http://vocaro.com/trevor/blog/2009/10/12/resize-a-uiimage-the-right-way/) – Torokh Oct 01 '11 at 21:07