IOS图片叠加效果

- (UIImage *)imageRotatedByDegrees:(CGFloat)degrees
   { 
      //calculate the size of the rotated view's containing box for ourdrawing space
     UIView *rotatedViewBox = [[UIView alloc]initWithFrame:CGRectMake(0,0,self.size.width,self.size.height)];
     CGAffineTransform t =CGAffineTransformMakeRotation(DegreesToRadians(degrees));
     rotatedViewBox.transform = t;
     CGSize rotatedSize = rotatedViewBox.frame.size;
     [rotatedViewBox release];
     
      //Create the bitmap context
     UIGraphicsBeginImageContext(rotatedSize);
     CGContextRef bitmap = UIGraphicsGetCurrentContext();
     
      //Move the origin to the middle of the image so we will rotate andscale around the center.
     CGContextTranslateCTM(bitmap, rotatedSize.width/2,rotatedSize.height/2);
     
      //  // Rotate the image context
     CGContextRotateCTM(bitmap, DegreesToRadians(degrees));
     
      //Now, draw the rotated/scaled image into the context
     CGContextScaleCTM(bitmap, 1.0, -1.0);
     CGContextDrawImage(bitmap, CGRectMake(-self.size.width / 2,-self.size.height / 2, self.size.width, self.size.height), [selfCGImage]);
     
     UIImage *newImage =UIGraphicsGetImageFromCurrentImageContext();
     UIGraphicsEndImageContext();
     return newImage;
     
   }


你可能感兴趣的:(IOS开发)