美文网首页
【iOS】UIImageView显示放大后的图片时模糊的问题

【iOS】UIImageView显示放大后的图片时模糊的问题

作者: CoderHuangRui | 来源:发表于2018-12-13 15:36 被阅读71次
原图,2x2像素
UIImageView中显示的效果

想放大后不进行模糊处理的话,需要更改一个属性

    UIImageView *imageView = [[UIImageView alloc] init];
    CALayer *layer = imageView.layer;
    layer.magnificationFilter = @"nearest";

文档中对 magnificationFilter 属性的解释如下


屏幕快照 2018-12-13 下午3.20.52.png

其中

typedef NSString * CALayerContentsFilter NS_STRING_ENUM;

可见 magnificationFilter 是一个 NSString 类型的属性
而它的值在文档中已经给出了 @"nearest" 或者是 @"linear"

layer.magnificationFilter = @"nearest";
设置该属性后的效果 Simulator Screen Shot - iPhone XR - 2018-12-13 at 15.36.08.png

相关文章

网友评论

      本文标题:【iOS】UIImageView显示放大后的图片时模糊的问题

      本文链接:https://www.haomeiwen.com/subject/wtfzxxtx.html