【问题标题】:resizableImageWithCapInsets images always misaligned?resizableImageWithCapInsets 图像总是未对齐?
【发布时间】:2013-01-19 15:27:24
【问题描述】:

是否可以创建一个正确对齐具有可调整大小图像的 UIImageView?

我尝试了所有方法(例如图像 2 的幂等),但无法正常工作。

UIImageView的坐标是:

po _Background

(UIImageView *) $1 = 0x14c42bd0 
<UIImageView: 0x14c42bd0;
frame = (16 38; 992 672);
opaque = NO;
autoresize = LM+RM+TM+BM;
userInteractionEnabled = NO;
layer = <CALayer: 0x14c42ba0>> - (null)

UIImage 本身为 96x96(视网膜,即 png 为 192x192,比例为 2)。可调整大小的 UIImage 是使用以下方法创建的:

UIEdgeInsets edgeInsets = UIEdgeInsetsMake(32, 32, 32, 32);
UIImage* resizableImage = [originalImage resizableImageWithCapInsets:edgeInsets];
[_Background setImage:resizableImage];

在模拟器中打开“颜色未对齐的图像”时,UIImageView _Background 会以黄色突出显示。在调试器中删除它的 UIImage:

[_Background setImage:nil];

去除黄色高光,即没有图像 -> 没有错位。

任何人都知道发生了什么以及如何确保它对齐?

谢谢。

【问题讨论】:

    标签: ios uikit core-graphics


    【解决方案1】:

    根据这个答案:What does yellow tinting represent when using "color misaligned images" on iPhone/iOS,黄色高亮表示图像被拉伸。由于这就是您对可调整大小图像的要求,因此总是如此是有道理的。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-03-03
      • 2011-06-26
      • 2012-01-30
      • 2019-05-20
      • 2012-10-12
      • 2023-03-12
      • 2017-11-03
      • 2016-10-26
      相关资源
      最近更新 更多