我有一个带有图像的UIButton,但是,图像似乎被移动了,其中一个边是黑色的。

更奇怪的是,边缘要么是侧面,要么是顶部,看起来是随机的。

UIButton是通过Interface添加的,我已经将内容模式设置为Aspect Fill。此外,在代码中,我设置了以下内容:
self.itemImage.imageView.contentMode = UIViewContentModeScaleAspectFill;有什么可以解释的吗?同样值得注意的是,这种情况只发生在设备上(iPhone 6,iOS8.4)。在模拟器中,没有像预期的那样有黑色的边缘。
发布于 2015-08-07 14:21:10
试着改变背景颜色,看看我们看到的黑色边缘是否是背景。
self.itemImage.imageView.backgroundColor = [UIColor yellowColor];如果边缘没有变黄,那么造成问题的可能是图像。
发布于 2015-08-06 12:35:49
试试这个..。
self.itemImage.imageView.contentMode = UIViewContentModeCenter;
https://stackoverflow.com/questions/31855644
复制相似问题