Last Updated: September 09, 2019
·
524
· IronLeash

Drawing 2 UIImage on each other

I use following approach to create a frame for a uiimage in my apps.Through this approach it is not necessary to use two separate UIImageViews which means less alive object.This is specially important for for performance issues of custom cells in UItableViews.

+(UIImage*)maskAnImageWithFrame:(UIImage*)originalImage
{
  UIImage *frameImage = [UIImage imageNamed:@"Frame.png"];

  UIGraphicsBeginImageContext(frameImage.size);

  [attachmentImage drawInRect:  CGRectMake(0,0, frameImage.size.width, frameImage.size.height)];

 [frameImage drawInRect:  CGRectMake(0,0, frameImage.size.width, frameImage.size.height)];

UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return newImage; 
}