I am trying to merge two UIImageView
s together into combinedView
. The issue I am encountering is that after I have added the self.firstImageView
and self.secondImageView
as subviews to my combinedView
, the output I get when I check the byte size of combinedView.image
is 0. I need combinedView.image
to be eventually passed to my backend in a JEPGRepresentation, so am unsure how else I could approach to combining the views together, or what I am doing incorrectly at the moment.
Thanks for your help!
UIImageView *combinedView = [[UIImageView alloc] init];
[combinedView addSubview:self.firstImageView];
[combinedView sendSubviewToBack:self.firstImageView];
[combinedView addSubview:self.secondImageView];
[combinedView bringSubviewToFront:self.secondImageView];
NSData *firstPicData = UIImageJPEGRepresentation(self.firstImageView.image, 1.0);
NSLog(@"Size of first:%d",[firstPicData length]); //outputs a non-zero number
NSData *secondPicData = UIImageJPEGRepresentation(self.secondImageView.image, 1.0);
NSLog(@"Size of second:%d",[secondPicData length]); //also outputs a non-zero number
NSData *combinedPicData = UIImageJPEGRepresentation(combinedView.image, 1.0);
NSLog(@"Size of combined:%d",[combinedPicData length]); //! outputs 0 bytes