图片合成

  

   UIImageView *imageBigger = [[UIImageView alloc] init];

    imageBigger.backgroundColor = [UIColor clearColor]; // 背景色设置为透明

    imageBigger.layer.backgroundColor = [UIColor colorWithRed:0 green:0 blue:0 alpha:0].CGColor;

    imageBigger.frame = self.view.bounds;

    

    UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 400, 400)];

    imageView.image = [UIImage imageNamed:@"hb"];

    imageView.backgroundColor = [UIColor clearColor];

    imageView.layer.backgroundColor = [UIColor colorWithRed:0 green:0 blue:0 alpha:0].CGColor;

    [imageBigger addSubview:imageView];

    

    UIImageView *imageView1 = [[UIImageView alloc] initWithFrame:CGRectMake(200, 200, 400, 400)];

    imageView1.image = [UIImage imageNamed:@"hb"];

    imageView1.backgroundColor = [UIColor clearColor];

    imageView1.layer.backgroundColor = [UIColor colorWithRed:0 green:0 blue:0 alpha:0].CGColor;

    [imageBigger addSubview:imageView1];

    

    UIGraphicsBeginImageContextWithOptions(imageBigger.bounds.size, NO, 0.0);

    [imageBigger.layer renderInContext:UIGraphicsGetCurrentContext()];

    UIImage *resultingImage=UIGraphicsGetImageFromCurrentImageContext();

    UIGraphicsEndImageContext();

 

 

  

posted @ 2018-09-11 09:47  zzlei  阅读(104)  评论(0编辑  收藏  举报