Создать новый растровый контекст:
CGColorSpaceRef colorspace = CGColorSpaceCreateDeviceGray();
CGContextRef newContext =
CGBitmapContextCreate(
NULL,
viewContainingAllUIImageViews.frame.size.width,
vViewContainingAllUIImageViews.frame.size.height,
8,
viewContainingAllUIImageViews.frame.size.width,
colorspace,
0);
CGColorSpaceRelease(colorspace);
Нарисуйте соответствующий фон в контексте:
CGContextSetRGBFillColor(newContext, 1.0, 1.0, 1.0, 1.0);
CGContextFillRect(newContext, CGRectMake(0, 0, viewContainingAllUIImageViews.frame.size.width, vViewContainingAllUIImageViews.frame.size.height));
Получите свойство CGImage
каждого изображения, которое содержит ваш UIImageView
, и нарисуйте все изображения в это одно изображение:
CGContextDrawImage(newContext, oneOfTheSubImageViews.frame, oneOfTheSubImageViews.image.CGImage);
Преобразование растрового контекста обратно в изображение:
CGImageRef newImage = CGBitmapContextCreateImage(newContext);
UIImage *flattenedImage = [UIImage imageWithCGImage:newImage];
Затем CFRelease
newContext
, newImage
, используйте UIImage
в UIImageView
и отбросьте все остальные UIImageView
с.