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 缩放/插值


- 用 Swift 实现 UITextFieldDelegate 2022-01-01
- Android viewpager检测滑动超出范围 2022-01-01
- 使用自定义动画时在 iOS9 上忽略 edgesForExtendedLayout 2022-01-01
- 如何检查发送到 Android 应用程序的 Firebase 消息的传递状态? 2022-01-01
- android 4中的android RadioButton问题 2022-01-01
- Android - 拆分 Drawable 2022-01-01
- 想使用ViewPager,无法识别android.support.*? 2022-01-01
- Android - 我如何找出用户有多少未读电子邮件? 2022-01-01
- MalformedJsonException:在第1行第1列路径中使用JsonReader.setLenient(True)接受格式错误的JSON 2022-01-01
- 在测试浓缩咖啡时,Android设备不会在屏幕上启动活动 2022-01-01