【发布时间】:2012-10-10 07:59:42
【问题描述】:
我有一个带有图像的 UIImageView。 initWithFrame:(CGRect)frame 看起来像这样:
#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;
然后我触发这个
- (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_;
}];
}
ImageView 正确缩放并绘制红色边框,但随后ImageView 内的image 从左侧边框下方突出大约一两个像素。我已经删除了图片,但这应该可以让您对问题有所了解:
有什么想法吗?
【问题讨论】:
-
确实是
self.layer.masksToBounds = YES;。已删除答案的神秘用户,请返回,以便我接受! -
您的问题还有更多问题 :)
标签: iphone objective-c xcode cocoa-touch uiimageview