Frank
Frank

Reputation: 507

Unusual case with UIImage and UIScrollView

I have UIScrollView and UIImage in it. I set an image to UIImage, but it looks differently(compressed) Here is my case. It's in Russian, but anyway you can see, how bad it looks.enter image description here

Before this I had the same thing with another UIViewController. I just stretched the image, so that it looked pretty good being compressed by apple wonders.enter image description here

Likely I am just doing everything wrong in this life. Help, please!

Upvotes: 0

Views: 45

Answers (1)

manecosta
manecosta

Reputation: 8772

I find it a bit hard to understand exactly what is your problem as you don't post any code and the images are a bit ambiguous.

From what I can see, if you're referring to the image that is creating that border around the text in the first image, what is clear to me is that the ratio of the image is not the same as how you're using it.

If you have a square image, and you use it as a rectangle, it will be stretched and deformed (assuming you're using AspectFill for the contentMode.

What you can do is to use a resizable image that can define which parts of the image should be stretched and which shouldn't. I would be something like:

UIImage *someImage = [UIImage imageNamed:@"someImage"];
UIImage *resizableImage = [someImage resizableImageWithCapInsets:UIEdgeInsetsMake(20, 20, 20, 20)];

The values I provided there as (20,20,20,20) are highly speculative as I don't know the size of your image. What they mean is the top/left/bottom/right parts of the image, measured in pixels that shouldn't be deformed.

Upvotes: 1

Related Questions