Reputation: 7456
I want to have a 60x60 UIImageView that displays my logo on the login screen.
In my image assets, I have the 60x60 .png in 1x and 120x120 .png in 2x. However, whenever I display these images something just seems a tad off. There seems to be the slightest but obvious blur.
I decided to test out the 120x120 image as a 3x image for the iPhone 6 Plus and was shocked to find that it looked perfect and wasn't blurry at all. This doesn't seem to add up to me since 120x120 pixels is not 3 times as much as 60x60.
Maybe I just don't understand how the image assets work, but how would I get this to all mesh properly?
Upvotes: 0
Views: 112
Reputation: 53830
When you have the content mode of the UIImageView set to UIViewContentModeScaleToFill
, the image will automatically get resized to fit the UIImageView, which can introduce some non-pixel perfect artifacts.
Set the mode to UIViewContentModeTopLeft
so that it doesn't get scaled, and you'll likely see that the UIImageView is not exactly the same size (in points) as the image.
Check the properties of the UIImageView, and the autoresizingmask or autolayout, or your code, to ensure that the dimensions of the UIImageView are correct.
Also, ensure that you are using the proper file naming convention (e.g. [email protected]
) and loading the image without specifying the suffix using imageNamed:
or imageForResource:
. If iOS weren't finding the image for the current screen scale and had to scale the image, you would get the same artifacts.
Upvotes: 0
Reputation: 3494
You could try changing the content mode, maybe try UIViewContentModeCenter.
Another option would be to check the storyboard and, if you are using constraints, not set any width/height constraints on your UIImageView. This will make the image view resize to fit the asset set inside.
Upvotes: 1