UIImageView scaling/interpolation

前端 未结 4 1453
南旧
南旧 2021-01-02 01:55

I have a small IPhone app that I am working on and I am displaying an image with a UIImageView. I am scaling it up using the Aspect Fit mode. I would like to have the imag

相关标签:
4条回答
  • 2021-01-02 02:25

    Swift

    imageView.layer.magnificationFilter = kCAFilterNearest
    imageView.layer.shouldRasterize = true
    
    0 讨论(0)
  • 2021-01-02 02:29

    You would need to set the magnificationFilter property on the view's layer to the nearest neighbour filter:

    [[view layer] setMagnificationFilter:kCAFilterNearest]
    
    0 讨论(0)
  • 2021-01-02 02:31

    There are two ways you could do this. You can either implement a rescaling algrorithm without interpolation. If this is to much work you could rescale the image in another application like gimp or photoshop. This would work unless you needed to change the size dynamically in your application.

    0 讨论(0)
  • 2021-01-02 02:35

    Make sure you include the line

    #import  <QuartzCore/CALayer.h>
    

    At the top of the file containing the call to setMagnificationFilter or it won't compile.

    0 讨论(0)
提交回复
热议问题