UIImageView 缩放/插值 [英] UIImageView scaling/interpolation

查看:26
本文介绍了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 缩放/插值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆