Joseph Anderson
Joseph Anderson

Reputation: 4144

ImageView Max Size iOS MonoTouch

I am creating an image from a byte array using a UIImageView control. I need to ensure that the max size of the image is 600 x 600. How can I do that? I have tried SizeThatFits() and SizeToFit(), however, that just moves the image around on the screen. I have tried setting the Bound property to new RectangleF(0, 0, 600, 600), however, that also does no good.

Upvotes: 0

Views: 154

Answers (1)

Maxim Korobov
Maxim Korobov

Reputation: 2572

You could check UIImage Size property for exceeding your limits. If so, scale it:

const int limit = 600;
if ((View.Frame.Size.Width > limit) || (View.Frame.Size.Height > limit))
{
    // Scale as on link above.
}

Alternatively, you could set Frame and ContentMode of your UIImageView to desirable values.

Upvotes: 1

Related Questions