美文网首页
UIImage 操作

UIImage 操作

作者: 秀才不才 | 来源:发表于2016-01-08 14:55 被阅读48次

    ps:东西太多了

    缩放
    - (UIImage *)scaleImage:(UIImage *)image toSize:(CGSize)size {
        
      UIImage *newImg;
        
      UIGraphicsBeginImageContext(size);
      CGRect imageRect = CGRectMake(0, 0, size.width, size.height);
      [image drawInRect:imageRect];
        
      UIImage *newImg = UIGraphicsGetImageFromCurrentImageContext();
    
      UIGraphicsEndImageContext();
        
      return newImg;
    }
    
    截取
    - (UIImage *)captureImage:(UIImage *)image toSize:(CGRect)rect {
        
    CGImageRef imageRef = CGImageCreateWithImageInRect(image.CGImage, rect);
    UIImage *captureImage = [UIImage imageWithCGImage:imageRef];
        
    CGImageRelease(imageRef);
        
    return captureImage;
    }
    

    相关文章

      网友评论

          本文标题:UIImage 操作

          本文链接:https://www.haomeiwen.com/subject/menfkttx.html