【问题标题】:Distorted content when scaling UIImageView缩放 UIImageView 时内容失真
【发布时间】:2012-10-24 23:02:30
【问题描述】:

我有一个 UIImageView,其框架为 (0, 0, 568, 300),其中包含一个原生大小为 512x384 像素的 UIImage。 contentmode 设置为 Aspect fit。 如果用户双击视图,我会使用以下代码更改 UIImageView 的大小:

self.imageViewerViewController.imageView.frame = CGRectMake(0, -63, 568, 426);

结果是图像的右边缘变形,无法正确缩放到新尺寸。

附上一张黑白矩阵的图像,失真在右边。 似乎右列像素重复到视图的右边缘。

谁能帮忙?

【问题讨论】:

    标签: iphone uiimageview scaling


    【解决方案1】:

    我已将受影响的 UIImageView 从 xib 文件的创建更改为在代码中创建它,并使用 - (id)initWithFrame:(CGRect)aRect: 方法和 aRect 的缩放图像的最大尺寸。现在图像已正确缩放。 显然xib文件中的UIImageView已经初始化了一个512x384像素的帧。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-12-23
      • 1970-01-01
      • 2020-10-01
      • 2012-05-27
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多