I am developing iOS App with SDWebImage.
I would like to trim central 100px*100px from downloaded image and set this in UIImageView.
I am writing down the following code, however not a trimmed image but an original downloaded image is set in NewsImage.
UIImageView *NewsImage = (UIImageView *)[cell viewWithTag:1];
[NewsImage setImageWithURL:imageURL
placeholderImage:placeholderImage
options:SDWebImageProgressiveDownload
completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType) {
int imageW = image.size.width;
int imageH = image.size.height;
int posX = (imageW - 100) / 2;
int posY = (imageH - 100) / 2;
CGRect trimArea = CGRectMake(posX, posY, 100, 100);
CGImageRef srcImageRef = [image CGImage];
CGImageRef trimmedImageRef = CGImageCreateWithImageInRect(srcImageRef, trimArea);
image = [UIImage imageWithCGImage:trimmedImageRef];
}];
Could you tell me how to solve this problem?