InterfaceBuilder has a UIImageView Fit . In the main controller, by reference I have an imageView , in which there is a UIImageView . The size is 280x280 , in the retina it should be 560х560 , but I'm doing something wrong.

A piece of code draws a chessboard, working with imageView :

 ... // Инициализируем значения // Ретина/не ретина scl = [[UIScreen mainScreen] scale]; // Размеры поля width = @(imageView.frame.size.width); height = width; // Размер клетки xstep = @(10); ystep = @(10); // Цвета клеток NSArray *c1 = @[ @0 .9, @0 .9, @0 .9 ]; NSArray *c2 = @[ @0 .8, @0 .8, @0 .8 ]; // Получаем контекст UIGraphicsBeginImageContextWithOptions(imageView.frame.size, NO, scl); ctx = UIGraphicsGetCurrentContext(); int len1 = @(ceil ( [width intValue] / [xstep intValue] )); int len2 = @(ceil ( [height intValue] / [ystep intValue] )); for (int xi = 0; xi < len1; xi++ ) { for (int yi = 0; yi < len2; yi++) { NSArray *c = (xi + yi) % 2 == 0 ? c1 : c2; CGContextSetRGBFillColor(ctx, [[c objectAtIndex:0] floatValue], [[c objectAtIndex:1] floatValue], [[c objectAtIndex:2] floatValue], 1.0); CGContextFillRect(ctx, CGRectMake( xi*[xstep intValue], yi*[ystep intValue], [xstep intValue], [ystep intValue])); } } // Записываем сформированный рисунок в наш UIImageView CGContextStrokePath(ctx); imageView.image = UIGraphicsGetImageFromCurrentImageContext(); 

As a result, the chessboard is drawn correctly 28x28 cells in the usual mode, but on retina there are also 28х28 , and it should be 56х56 .

  • > but on their retina also 28x28 And they are bigger, of course? - VioLet
  • Yes, they are also 28 and they are large. Those. I have all the same chess field 280x280, and should be 560x560, and accordingly the cells, also 56x56. - ALiEN
  • @Sergey Vanichkin as a crutch solution, you can again multiply the width (= length) of the field by 2, thereby obtaining the desired number of cells. But this is probably not worth doing. And you did not try to specify 0 as the last parameter in UIGraphicsBeginImageContextWithOptions() - automatic multiplier determination? - VioLet
  • Yes, I tried, but it does not affect the result. - ALiEN
  • In fact, the guys from Apple made sure that no one bothers what kind of display at the end user. Points are used - therefore the result on the ordinary and on the retina is the same and should be the same. - zhenyab

0