1

I have a few UIVies butted edge to edge. THe views completely cover the superView. Looks great in display, but when rendered the adjoining edges are visible, that is to sat a line appears between them. Since the views look perfect in display, I imagine it must be interpolation of the pixels of the views that causes this.

Anyone know how to fix this?

The image below is a render. On the device or simulator the lines would not be visible. enter image description here

render code

-(void)renderImage {
    CGSize renderSize = CGSizeMake(masterView.frame.size.width, masterView.frame.size.height);
    UIGraphicsBeginImageContext(renderSize);
    CGContextRef context = UIGraphicsGetCurrentContext();
    CGContextSaveGState(context);
    CGContextConcatCTM(context, [[masterView layer] affineTransform]);
    [[masterView layer] renderInContext:UIGraphicsGetCurrentContext()];
    renderedImage = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();
    CGContextRestoreGState(context);
    UIImageWriteToSavedPhotosAlbum(renderedImage, self, @selector(image:didFinishSavingWithError:contextInfo:), nil);
    masterView.transform = CGAffineTransformIdentity;
}
OWolf
  • 5,012
  • 15
  • 58
  • 93

2 Answers2

1

Core graphics attempts to anti alias your views. You need to tell it not to do that.

Consider the following example which renders self, a UIView, as a UIImage without anti aliasing:

UIGraphicsBeginImageContextWithOptions(self.bounds.size, YES, [[UIScreen mainScreen] scale]);
CGContextSetAllowsAntialiasing(UIGraphicsGetCurrentContext(), FALSE);
[self.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
rhummelmose
  • 647
  • 4
  • 15
-1

try:

UIGraphicsBeginImageContextWithOptions(renderSize, false, [[UIScreen mainScreen] scale]);

instead of:

UIGraphicsBeginImageContext(renderSize);
peko
  • 11,267
  • 4
  • 33
  • 48
  • Thanks for the suggestion! So far this did not fix the problem. Any tip as to why you suggested this, might be helpful. – OWolf Apr 26 '13 at 04:19