首页 > 代码库 > Core Graphics 学习——1 两张图合成为一张图

Core Graphics 学习——1 两张图合成为一张图

-(UIImage *)MergeTwoImage
{
    UIImage * img =[UIImage imageNamed:@"icon"];
    CGSize sz = img.size;
    UIGraphicsBeginImageContextWithOptions(CGSizeMake(sz.width*2, sz.height), NO, 0);
    [img drawAtPoint:CGPointMake(0, 0)];
    [img drawAtPoint:CGPointMake(sz.width, 0)];
    UIImage *mergeImg = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();
    return mergeImg;
}