屏蔽UITableViewCell(视差效果)

时间:2014-01-15 09:39:22

标签: ios objective-c uitableview

在我的应用程序中,我试图在我的桌子上获得一个副作用。 (例如它的背景),其中包含每个条目的模糊地图。

我是如何设置的,我有一个XIB UITableViewCell,并已将标签添加到contentView。然后在代码中我将图像添加到backgroundView。 (backgroundView不存在,我创建了一个“空视图”到我添加图像的位置)。

然后我将UIInterpolatingMotionEffect添加到图片视图。

这很有效。但是,由于图像具有与表格视图单元格相同的尺寸,因此当人们倾斜手机并且出现白色边缘的旁路效果时。如下图所示。

White edges with paralax

这不是我想要的。所以我想,我可以在backgroundView中放一个更大的图像。这在我不处于编辑模式时有效。但在编辑模式下,背景图像部分与删除按钮重叠。如下所示:

Overlap in editing mode

所以我想,我应该剪辑包含图像视图的backgroundView。我已经完成了以下代码:

self.backgroundView.clipsToBounds = YES;

或者

// Create a mask layer and the frame to determine what will be visible in the view.
CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init];
CGRect maskRect = self.bounds;

// Create a path with the rectangle in it.
CGPathRef path = CGPathCreateWithRect(maskRect, NULL);

// Set the path to the mask layer.
maskLayer.path = path;

// Release the path since it's not covered by ARC.
CGPathRelease(path);

// Set the mask of the view.
self.backgroundView.layer.mask = maskLayer;

但两种解决方案都不起作用。看起来它没有被剪裁。还有其他方法可以解决这个问题吗?

0 个答案:

没有答案
相关问题