現在、コンテキストを三角形にクリップしていますが、その三角形内に画像を描画すると、エッジがぎざぎざになります。Retina ディスプレイでは本当にひどく見えます (他のデバイスではまだテストしていません)。UIViewEdgeAntialiasing
アプリケーションの .plist ファイルに設定しようとしYES
ましたが、コンテキストのアンチエイリアシングを有効にしました。
これはコードです:
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSetAllowsAntialiasing(context, YES);
CGContextSetShouldAntialias(context, YES);
CGContextSaveGState(context);
CGContextSetShadowWithColor(context, CGSizeMake(1, 1), 3, UIColorFromRGB(0x000000, 0.12).CGColor);
CGContextSetFillColorWithColor(context, [UIColor redColor].CGColor);
CGMutablePathRef rightCornerCutOut = CGPathCreateMutable();
CGPathMoveToPoint(rightCornerCutOut, NULL, self.offset, self.offset);
CGPathAddLineToPoint(rightCornerCutOut, NULL, self.cutOutSize-self.offset, self.offset);
CGPathAddLineToPoint(rightCornerCutOut, NULL, self.offset, self.cutOutSize-self.offset);
CGPathCloseSubpath(rightCornerCutOut);
CGContextAddPath(context, rightCornerCutOut);
CGContextFillPath(context);
CGContextAddPath(context, rightCornerCutOut);
CGContextClip(context);
CGRect imgRect = CGRectMake(0,0,self.cutOutSize,self.cutOutSize);
[myImage drawInRect:imgRect];
CGContextRestoreGState(context);