Forum Xamarin.iOS

Why are my images pixelated? In both UIImageView & UIButtonType.Custom w/ image...

TrevorYokumTrevorYokum USMember ✭✭

Hey Xamarin.iOS, having a bit of a problem here. I have a custom icon bar at the bottom of my app that has 4 different buttons on it. As the title says, I tried to create a custom UIButton from the same type; the problem I'm having is that my image comes out pixelated when rendered. I have a 27x27 icon that is crisp and clear on my coworker's sister Android app, but when I put that same image into my app, it's pixelated and looks as if there's no anti aliasing.

My 27x27 image is contained by the button, whose .Frame is like so: new CGRect(80, View.Frame.Bottom, 27, 27). Why is it pixelated? I've attempted to set the button's .VerticalAlignment and .HorizontalAlignment to UIControlContentVerticalAlignment.Fill and UIControlContentHorizontalAlignment.Fill to no avail. I saw someone answer that instead of doing a button, try UIImageView with a gesture recognizer and UserInteractionEnabled turned on. I tried this, but the same thing happened: pixelated/jagged image.

Does anyone know why this would be happening?

Best Answer


  • TrevorYokumTrevorYokum USMember ✭✭
    edited April 2017

    @BytesGuy Ah, yes, I remember seeing something about this in the beginning of development. So, independent of using the bundles or image sets, how would I do this? I just tried what you suggested, keeping my button's .Frame at 27 width x 27 height, and setting its image to my new 54x54 image. Now the image/button simply doesn't display. Am I missing something?

    Thanks for the quick reply!

    Edit: Also, for info, I'm using/testing on an iPhone 6 Plus; just read that the 6 Plus would require a 3x image. But if 54x54 doesn't even display, why would 81x81?

Sign In or Register to comment.