Perfect monotone image

Background:

I need to get a basic understanding of how to present perfect pixel images on iOS devices using MonoTouch. My understanding of the iOS ecosystem is currently limited as a developer of the Windows platform for the past 18 years. From what I understand, there is a common coordinate system that makes views the same regardless of whether it is a retina screen or an old iPhone 3G display.

The question arises:

What is the best way to create and display images without blurring or distortion using MonoTouch?

// AnkMannen

+4
source share
1 answer

The first thing you need to know is the retina display iOS system.

All controls are located in coordinates, as if they were 3GS / iPad 2 or older. Devices with a retina display, such as the iPhone 4, 5 and iPad 3, use the same coordinates, but with double the size of the screen.

For images, use PNG. You will have 2 sets, one for the smaller display and one for the retina screen. Apple uses the file naming convention:

  • yourImage.png - smaller image for 3GS
  • yourImage@2x.png - enlarged image for retina displays

Suppose an image is 150 pixels by 50 pixels with a smaller size. To correctly display it in C #:

 //This code is in the ViewDidLoad method of a UIViewController var imageView = new UIImageView(new RectangleF(0, 0, 150, 50)); imageView.Image = UIImage.FromFile ("yourImage.png"); View.AddSubView(imageView); 

iOS will load an image of the appropriate size (by naming convention) and place it in the upper left corner of the screen. Keeping the right size for imageView also prevent any distortion. On retina displays, iOS will download a larger 300x100 image and look the same (except for much sharper) on smaller screens side by side.

+7
source

Source: https://habr.com/ru/post/1447964/


All Articles