Resize UIImage to 200x200pt/px

前端 未结 13 2077
后悔当初
后悔当初 2020-11-27 11:25

I have been struggling resizing an image. Basically I have stumpled upon: How to scale down a UIImage and make it crispy / sharp at the same time instead of blurry?

13条回答
  •  醉梦人生
    2020-11-27 11:49

    If you are using kingfisher lib for loading images in you project and want to resize it here is the way:

  • Xcode 8
  • Swift 3x

    let imageUrl = URL(string: "your image url")
     //Size refer to the size which you want to resize your original image
     let size = CGSize(width: 60, height: 60)
     let processImage = ResizingImageProcessor(targetSize: size, contentMode: .aspectFit)
     cell.courseTitleImage.kf.setImage(with: imageUrl! , placeholder: UIImage(named: "placeholder"), options: [.transition(ImageTransition.fade(1)), .processor(processImage)], progressBlock: nil, completionHandler: nil)
    

    OR

    Resize Local Image:- you can refer to the answer of @Christoph R

提交回复
热议问题