I want to make rounded photo from Facebook, but image always scales.
So i have Storyboard with next parameters: http://prntscr.com/5bpuqy
align center X, align center Y, width equals 72, height equals 72. I understand, that problem may be in 72/72, but image mode in storyboard is "Aspect Fit"
I call my methods for downloading image by URL and then make it cornered with radius.
// call
[UIImage setRoundImageView:self.p_photo WithURL:[p_user fullURL] withCornerSize:37];
+ (void)setRoundImageView:(UIImageView *)imageView WithURL:(NSURL *)url withCornerSize:(CGFloat)corner
{
dispatch_async(dispatch_get_global_queue( DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^(void){
[[SDWebImageManager sharedManager] downloadImageWithURL:url
options:0
progress:^(NSInteger receivedSize, NSInteger expectedSize) {
} completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, BOOL finished, NSURL *imageURL) {
if (image && finished)
{
[self setRoundImage:image forImageView:imageView withCornerSize:corner];
}
}];
});
}
+ (void)setRoundImage:(UIImage *)image forImageView:(UIImageView *)imageView withCornerSize:(CGFloat)corner
{
dispatch_async(dispatch_get_main_queue(), ^{
UIGraphicsBeginImageContextWithOptions(imageView.bounds.size, NO, [UIScreen mainScreen].scale);
[[UIBezierPath bezierPathWithRoundedRect:imageView.bounds
cornerRadius:corner] addClip];
[image drawInRect:imageView.bounds];
imageView.image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
});
}