开发者

iPhone - Make a small image fill a custom larger button

I have a UIButton in which I want to insert an image that would stretch to the button size. The button prope开发者_JAVA百科rty 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 ?


Set the image as the background image of the button.


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


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.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜