为什么我的UIImageView边框左侧会出现一条窄的白线?

Cen*_*ion 1 iphone border objective-c uiimageview

UIViewImage左侧出现不需要的白色1像素线.我正在使用QuartzCore来应用边框:

...
UIImageView *imageView = [[UIImageView alloc] initWithImage:image];

[imageView.layer setBorderColor: [[UIColor BORDERCOLOR4ALLVIEWS] CGColor]];
[imageView.layer setBorderWidth: BORDERSIZE4ALL];
...
Run Code Online (Sandbox Code Playgroud)

图像视图位于ScrollView中.我在屏幕底部有一个缩略图列表.当用户点击缩略图时,我正在加载图像并将其传递给MyUIImageView.image.这是在点击时执行的代码:

MyUIImageView.image = [UIImage imageNamed:imageName];
CGRect rect = MyUIImageView.frame;
rect.size.width = MyUIImageView.image.size.width; //also tried with - 1;
rect.size.height = MyUIImageView.image.size.height //also tried with - 1;

MyUIImageView.frame = rect; 

// also tried redraw a border on the image view:

[MyUIImageView.layer setBorderColor: [[UIColor BORDERCOLOR4ALLVIEWS] CGColor]];
[MyUIImageView.layer setBorderWidth: BORDERSIZE4ALL];
Run Code Online (Sandbox Code Playgroud)

注意到该行仅出现在一个图像上.但是,如果我通过减去-1来使图像视图帧大小更小,那么其他图像上也会出现白线.以下是带有白线的图像示例:

在此输入图像描述

Cen*_*ion 7

将MyUIImageView.clipsToBounds设置为YES后,白线消失了:)