Retina @2x ディスプレイで幅 3 ピクセルの線を作成しようとしています。簡単なアイデアは、1.5 幅の線を作成することです。
UIGraphicsBeginImageContextWithOptions(CGSizeMake(20, 20), NO, 0.0f);
CGContextRef aRef = UIGraphicsGetCurrentContext();
CGContextSetAllowsAntialiasing(aRef, NO);
CGContextSetShouldAntialias(aRef, NO);
UIBezierPath* bezierPath = UIBezierPath.bezierPath;
[bezierPath moveToPoint: CGPointMake(10, 0)];
[bezierPath addLineToPoint: CGPointMake(10, 10)];
bezierPath.lineWidth = 1.5;
[bezierPath stroke];
UIImage * myImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
しかし、最終的には、画面上に 4 ピクセルの線幅が表示されます。
問題は、iPad 3 (Retina @2x) を使用していて、定義済みのシステム ボタン UIBarButtonSystemItemAdd で UIBarButtonItem を使用すると、十字の 2 つのパスが画面上で 3 ピクセル幅になることです。