Create a single image by combining multiple images in iOS

I am using UIImageView and I need to set more than one image as background.

All images have a transparent background and contain any symbol in the corners. Images are saved depending on conditions. There is also the possibility that there may be more than one image.

I am currently installing images, but I can only view the last image. Therefore, I want all images to be displayed together.

Please let me know if there is another way by which I can convert multiple images into one image.

Any help would be appreciated

Thank you in advance

+4
source share
4

. , UIImage, drawAtPoint:blendMode:alpha:. , kCGBlendModeNormal .

+2

- , -.

,

  • UIGraphicsBeginImageContextWithOptions ( , )
  • CGContextDrawImage
  • UIGraphicsGetImageFromCurrentImageContext, UIImage, .
+1

, . :

-(UIImage *)blendImages:(NSMutableArray *)array{

    UIImage *img=[array objectAtIndex:0];
    CGSize size = img.size;
    UIGraphicsBeginImageContext(size);

     for (int i=0; i<array.count; i++) {
        UIImage* uiimage = [array objectAtIndex:i];
        [uiimage drawAtPoint:CGPointZero blendMode:kCGBlendModeNormal alpha:1.0];
     }
     return UIGraphicsGetImageFromCurrentImageContext();
}

, .

+1

:

typedef enum _imageType{
  image1,
  image2,
  ...
  imageN
}imageType;

and declare in @interface

imageType imgType;

in the .h file.

And in the .m file

-(void)setImageType:(imageType)type{
  imgType = type;
}

and then you can use the setImageType: function to set any images you want.

0
source

Source: https://habr.com/ru/post/1525732/


All Articles