Ios drawRect产生锯齿状线条(使用抗锯齿处理-无效)
我目前正在将我的背景剪辑成一个三角形,当我在这个三角形中绘制图像时,我会看到锯齿状的边缘。它们在视网膜显示器上看起来非常糟糕(还没有在其他设备上测试过)。我已尝试将应用程序的.plist文件中的Ios drawRect产生锯齿状线条(使用抗锯齿处理-无效),ios,iphone,objective-c,retina-display,drawrect,Ios,Iphone,Objective C,Retina Display,Drawrect,我目前正在将我的背景剪辑成一个三角形,当我在这个三角形中绘制图像时,我会看到锯齿状的边缘。它们在视网膜显示器上看起来非常糟糕(还没有在其他设备上测试过)。我已尝试将应用程序的.plist文件中的uiviewedgentialiasing设置为YES,并确保为我的上下文启用抗锯齿 代码如下: CGContextRef context = UIGraphicsGetCurrentContext(); CGContextSetAllowsAntialiasing(context, YES); CGCo
uiviewedgentialiasing
设置为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);
此代码实际上在
drawRect:
中,您没有直接调用它吗?@Wain是的,它在-drawRect:
中,不,我没有直接调用它。这可能有助于发布您得到的图片。@ipmcc我添加了一个图像。请看一看。您是否尝试将CGContextSetShouldAntialias
调用放在CGContextSaveGState
之后?