UIImageView 缩放/插值

UIImageView scaling/interpolation(UIImageView 缩放/插值)
本文介绍了UIImageView 缩放/插值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个我正在开发的小型 iPhone 应用程序,我正在显示一个带有 UIImageView 的图像.我正在使用 Aspect Fit 模式将其放大.我想让图像在没有插值/平滑的情况下放大(我希望它看起来像素化).有什么办法可以改变这种行为吗?

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 image scale up with no interpolation/smoothing (I want it to look pixellated). Is there any way I can change this behavior?

一个更普遍的问题是我可以实现自己的缩放算法,还是有其他可以选择的内置算法?

A little more general question would be can I implement my own scaling algorithm, or are there other built in ones that I can select?

推荐答案

您需要将视图层的 magnificationFilter 属性设置为最近邻过滤器:

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

[[view layer] setMagnificationFilter:kCAFilterNearest]

这篇关于UIImageView 缩放/插值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

Pushing UIViewController above UITabBar(将UIView控制器推送到UITabBar上方)
java.lang.IllegalStateException: SimpleTypeImpl should not be created for error type(异常:不应为错误类型创建SimpleTypeImpl)
Android IllegalArgumentException: The tag for fragment_XXX is invalid. Received: layout-sw600dp/fragment_XXX_0(Android IlLegalArgumentException:Fragment_XXX的标签无效。收到:Layout-sw600dp/Fragment_XXX_0)
iOS convert audio sample rate from 16 kHz to 8 kHz(IOS将音频采样率从16 kHz转换为8 kHz)
Enforcing an audio sampling rate in iOS(在iOS中强制音频采样率)
HTTPS request using volley(使用 volley 的 HTTPS 请求)