I have an UIImageView which has an image. The initWithFrame:(CGRect)frame looks like this:
#define BORDER_WIDTH_SELECTION 3
#define SELECTED_SCALE_VALUE 1.3
self.layer.masksToBounds = NO;
smallFrame_ = frame;
float newX = self.center.x - ((self.frame.size.width*SELECTED_SCALE_VALUE)*0.5);
float newY = self.center.y - ((self.frame.size.height*SELECTED_SCALE_VALUE)*0.5);
bigFrame_ = CGRectMake(newX, newY, self.frame.size.width*SELECTED_SCALE_VALUE, self.frame.size.height*SELECTED_SCALE_VALUE);
self.layer.borderWidth = BORDER_WIDTH_SELECTION;
then later I trigger this
- (void) setSelected {
[self makeThumbnailBig];
self.layer.borderColor = [UIColor colorWithRed:178.0/255.0 green:19.0/255.0 blue:50.0/255.0 alpha:1.0].CGColor;
}
- (void)makeThumbnailBig
{
[UIView animateWithDuration:0.2 animations:^{
self.frame = bigFrame_;
}];
}
The ImageView scales correctly and draws a red border, but then the image within the ImageView peaks out from underneath the border on the left by about a pixel or two. I have removed the image, but this should give you an idea of the issue:

Any ideas?
In your code there is a line
According to the question it should be
YESinsteadAbout extra pixels:
When you are preparing the image size by division you could face the issue of magic image high resolution optimization. It starts by adding the fractal part to the UIImageView dimension. See Points Versus Pixels