리소스의 이미지 가져오기
[UIImage imageNamed:@"image_resource_name"]
UImage copy
UIImage *source = [UIImage imageNamed:@"src.png"];
CGSize size = [source size];
UIGraphicsBeginImageContext(size);
CGRect rect = CGRectMake(0, 0, size.width, size.height);
[source drawInRect:rect blendMode:kCGBlendModeNormal alpha:1.0];
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextStrokeRect(context, rect);
UIImage *testImg = UIGraphicsGetImageFromCurrentImageContext(); // <- 결과 이미지
UIGraphicsEndImageContext();
URL에서 이미지 읽어오기
NSURL *imageURL = [NSURL URLWithString:@"http://example.com/demo.jpg"];
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_BACKGROUND, 0), ^{
NSData *imageData = [NSData dataWithContentsOfURL:imageURL];
dispatch_async(dispatch_get_main_queue(), ^{
// Update the UI
self.imageView.image = [UIImage imageWithData:imageData];
});
});
http://stackoverflow.com/questions/7694215/create-a-uiimage-with-a-url-in-ios