I have a UIButton
that downloads its image from the network, I want the content mode to be "aspect fill", so I did this:
btn.imageView.contentMode = UIViewContentModeScaleAspectFill;
then I simply call:
[btn setImage:image forState:UIControlStateNormal];
And this works for images those are larger than the button. They are scaled to fit in the button with aspect ratio unchanged. But for images those are smaller than the button, they are simply displayed at the center without being stretched.
To fix this I tried making an resizable image with the image I retrieved, then call setImage:forState:
on my button, but this didn't work.
So I end up having to manually draw a resized image for each image that is smaller than my button then using the drawn image for my button, but I don't like this solution.
So my question is how can I get smaller images scaled properly on my button without having to manually draw a resized image for that every time?