在storyborad中拖拽UIImageView
//关联属性
@property (weak,nonatomic) IBOutlet UIImageView *imageView;
- (void)touchesBegan:(NSSet *)touches withEvent :(UIEvent *)event{
//图片的网络途径
//加载图片
NSData *data = [NSData dataWithContentsOfURL:url];
//生成图片
UIImage *image = [UIImage imageWithData:data];
//回到主线程
dispatch_async(dispatch_get_main_queue(),^{
self.imageView.image = image;
});
}