Saving 2 UIImages to one while saving rotation, resize info and its quality

后端 未结 2 1861
刺人心
刺人心 2021-01-19 05:05

I want to save 2 UIImages that are moved, resized and rotated by user. The problem is i dont want to use such function as any \'printscreen one\', because it makes both imag

2条回答
  •  刺人心
    刺人心 (楼主)
    2021-01-19 05:30

    Try this:

    UIImage *temp = [[UIImage alloc] initWithCGImage:image1 scale:1.0 orientation: yourOrientation];
    [temp drawInRect:CGRectMake(0, 0, image1.size.width, image1.size.height)];
    

    Similarly for image2. Rotation and resizing are handled by orientation and scale respectively. yourOrientation is a UIImageOrientation enum variable and can have a value from 0-7(check this apple documentation on different UIImageOrientation values). Hope it helps...

    EDIT: To handle rotations, just write the desired orientation for the rotation you require. You can rotate 90 deg left/right or flip vertically/horizontally. For eg, in the apple documentation, UIImageOrientationUp is 0, UIImageOrientationDown is 1 and so on. Check out my github repo for an example.

提交回复
热议问题