Resize UIImage and change the size of UIImageView

后端 未结 7 1038
梦谈多话
梦谈多话 2020-12-13 04:37

I have this UIImageView and I have the values of its max height and max width. What I want to achieve is that I want to take the image (with any aspect ratio an

7条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-13 04:56

       if([[SDWebImageManager sharedManager] diskImageExistsForURL:[NSURL URLWithString:@"URL STRING1"]])
       {
           NSString *key = [[SDWebImageManager sharedManager] cacheKeyForURL:[NSURL URLWithString:@"URL STRING1"]];
    
           UIImage *tempImage=[self imageWithImage:[[SDImageCache sharedImageCache] imageFromDiskCacheForKey:key] scaledToWidth:cell.imgview.bounds.size.width];
           cell.imgview.image=tempImage;
    
       }
       else
       {
           [cell.imgview sd_setImageWithURL:[NSURL URLWithString:@"URL STRING1"] placeholderImage:nil completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL)
            {
                UIImage *tempImage=[self imageWithImage:image scaledToWidth:cell.imgview.bounds.size.width];
                cell.imgview.image=tempImage;
    //                [tableView beginUpdates];
    //                [tableView endUpdates];
    
            }];
       }
    

提交回复
热议问题