How to merge two images after rotate the image?

前端 未结 2 798
遇见更好的自我
遇见更好的自我 2021-01-26 07:46

\"enter

After rotate the image how to merge the rotation image? I using the below code, It

相关标签:
2条回答
  • 2021-01-26 08:19

    If you want while device orientation use this code

    - (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration
    {
    if (toInterfaceOrientation == UIInterfaceOrientationLandscapeLeft ||
        toInterfaceOrientation == UIInterfaceOrientationLandscapeRight)
    {
        //Your cgrectmake for landscape
    }
    else
    {
        //Your cgrectmake for Portrait
    }
    }
    
    0 讨论(0)
  • 2021-01-26 08:22

    Add this method call this after rotation:

    -(UIImage *)getMergedImage
    {
     UIImage mergedImage;
     UIGraphicsBeginImageContext(backgroundImageView.frame.size)
     [backgroundImageView.layer  renderInContext:UIGraphicsGetCurrentContext];//bacgroundImageView here
     UIImage overLappedImage = [self getOverlappedImage];
     if(overLappedImage)
     {
       //CGRectMake(0,0,rsImageView.frame.width,rsImageView.frame.height)
       [overLappedImage drawInRect:rsImageView.frame blendMode:kCGBlendModeNormal alpha:0.8];//TopMostImageView here
     }
     mergedImage = UIGraphicsGetImageFromCurrentImageContext(); 
     UIGraphicsEndImageContext();
     return mergedImage;
    }
    

    Add this method to get overlappped Image.

    -(UIImage *)getOverlappedImage
    {
      UIImage overlappedImage;
      UIGraphicsBeginImageContext(rsImageView.frame.size)
      [rsImageView.layer renderInContext:UIGraphicsGetCurrentContext]; //TopMostImageView here
      overlappedImage = UIGraphicsGetImageFromCurrentImageContext(); 
      UIGraphicsEndImageContext();
      return overlappedImage;
    }
    
    0 讨论(0)
提交回复
热议问题