GCD队列组1

// 下载 - > 合并 - > 显示
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
    
//        @"http://img04.tooopen.com/images/20130712/tooopen_17270713.jpg"
//        @"https://www.baidu.com/img/bd_logo1.png"
    
   dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
       // 下载第一张
        NSString *urlString1 = [NSString stringWithFormat:@"http://img04.tooopen.com/images/20130712/tooopen_17270713.jpg"];
       // 下载第二张
        NSString *urlString2 = [NSString stringWithFormat:@"https://www.baidu.com/img/bd_logo1.png"];
        
        NSURL *url1 = [NSURL URLWithString:urlString1];
        NSURL *url2 = [NSURL URLWithString:urlString2];
        
        UIImage *image1 = [UIImage imageWithData:[NSData dataWithContentsOfURL:url1]];
        UIImage *image2 = [UIImage imageWithData:[NSData dataWithContentsOfURL:url2]];
        
        // 得到图片上下文
//       ou use this function to configure the drawing environment for rendering into a bitmap.
//       用这个函数 配置或者装载 用来表现 图片的环境
        UIGraphicsBeginImageContextWithOptions(image1.size, NO, 0.0f);
       
       // 绘制图片
        [image1 drawInRect:CGRectMake(0, 0, image1.size.width, image1.size.height)];
                [image2 drawInRect:CGRectMake(0, 0, image2.size.width, image2.size.height)];
       
       // 得到上下文的图片
        UIImage *fullImage = UIGraphicsGetImageFromCurrentImageContext();
       
       
       // 返回主队列
       dispatch_async(dispatch_get_main_queue(), ^{
           self.imageView.image = fullImage;
       });
       
       // 结束上下文
        UIGraphicsEndImageContext();
        
    });
        
        
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值