How to combine/ merge 2 images into 1

后端 未结 8 997
粉色の甜心
粉色の甜心 2020-12-07 12:32

I would like to know what to do to save 2 images into 1 image.

One of the photos can be moved, rotated and zoomed in/out...

I\'m doing this, but it basically

8条回答
  •  醉梦人生
    2020-12-07 13:10

    You can use this method, which is very dynamic and you can specify the starting position of the second image and total size of the image.

    -(UIImage *) addImageToImage:(UIImage *)img withImage2:(UIImage *)img2 andRect:(CGRect)cropRect withImageWidth:(int) width     
    {
    
        CGSize size = CGSizeMake(width,40);
        UIGraphicsBeginImageContext(size);
    
        CGPoint pointImg1 = CGPointMake(0,0);
        [img drawAtPoint:pointImg1];
    
         CGPoint pointImg2 = cropRect.origin;
         [img2 drawAtPoint: pointImg2];
    
         UIImage* result = UIGraphicsGetImageFromCurrentImageContext();
         UIGraphicsEndImageContext();
         return result;
    }
    

提交回复
热议问题