UIimage 剪切

来源:互联网 发布:淘宝室内设计师招聘 编辑:程序博客网 时间:2024/04/29 15:57
-(UIImage*)getSubImage:(CGRect)rect cgImage:(UIImage*)CGImage{    CGImageRef subImageRef = CGImageCreateWithImageInRect(CGImage.CGImage, rect);    CGRect smallBounds = CGRectMake(0, 0, CGImageGetWidth(subImageRef), CGImageGetHeight(subImageRef));    UIGraphicsBeginImageContext(smallBounds.size);    CGContextRef context = UIGraphicsGetCurrentContext();    CGContextDrawImage(context, smallBounds, subImageRef);    UIImage* smallImage = [UIImage imageWithCGImage:subImageRef];    UIGraphicsEndImageContext();    return smallImage;}

0 0
原创粉丝点击