UITableViewCell中的自定义UIImageView
我创建了UIImageView的一个子类来传递一些字符串。我还创建了UITableViewCell的自定义类,并将四个UIStringImageView放在其中 我这样做是为了一个像缩略图tableView这样的图库。 然后,我向每个UIStringImageView添加了一个UITapGestureRecognitor,以打开相应的图像 现在,我想在UIStringImageView上添加一个覆盖,在单个ImageView上显示不透明度 下面是我从UIStringImageView实现中获得的代码:UITableViewCell中的自定义UIImageView,uitableview,uiimageview,uigesturerecognizer,touchesbegan,Uitableview,Uiimageview,Uigesturerecognizer,Touchesbegan,我创建了UIImageView的一个子类来传递一些字符串。我还创建了UITableViewCell的自定义类,并将四个UIStringImageView放在其中 我这样做是为了一个像缩略图tableView这样的图库。 然后,我向每个UIStringImageView添加了一个UITapGestureRecognitor,以打开相应的图像 现在,我想在UIStringImageView上添加一个覆盖,在单个ImageView上显示不透明度 下面是我从UIStringImageView实现中获得的
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
overlay = [[UIView alloc] initWithFrame:self.frame];
[overlay setBackgroundColor:[UIColor colorWithWhite:0 alpha:0.5]];
[self addSubview:overlay];
}
代码运行良好。但我的问题实际上是,覆盖层不在ImageView的顶部,而是从顶部和左侧偏移。每个视图的顶部偏移量相同,每个imageView的左偏移量从左到右增加
带有两个重叠的屏幕截图左下一行的第一个和第二个imageView:
有人能帮我解决这个问题吗?谢谢!朱利安对于每个遇到类似问题的人: 使用self.bounds而不是self.frame解决了这个问题