UIImageView scaling/interpolation(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 缩放/插值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:UIImageView 缩放/插值
基础教程推荐
- 如何从 logcat 中删除旧数据? 2022-01-01
- navigator.geolocation.getCurrentPosition 在 Android 浏览器上 2022-01-01
- libGDX 从精灵或纹理中获取像素颜色 2022-01-01
- Cocos2d iPhone 非矩形精灵触摸检测 2022-01-01
- 通过重定向链接在 Google Play 中打开应用 2022-01-01
- iOS4 创建后台定时器 2022-01-01
- AdMob 广告未在模拟器中显示 2022-01-01
- Android:getLastKnownLocation(LocationManager.NETWORK_PROVIDER 2022-01-01
- NSString intValue 不能用于检索电话号码 2022-01-01
- iPhone - 获取给定地点/时区的当前日期和时间并将其与同一地点的另一个日期/时间进行比较的正确方法 2022-01-01
