我想在iOS中的uicollectionview中向单元格内容视图添加幻灯片形状。我在
中这样做collectionView cellForItemAtIndexPath:
UIBezierPath *aPath = [UIBezierPath bezierPath];
// Set the starting point of the shape.
[aPath moveToPoint:CGPointMake(cell.frame.size.width-15, 0.0)];
// Draw the lines.
[aPath addLineToPoint:CGPointMake(0.0, 0.0)];
[aPath addLineToPoint:CGPointMake(15, cell.frame.size.height)];
[aPath addLineToPoint:CGPointMake(cell.frame.size.width, cell.frame.size.height)];
[aPath closePath];
[self setClippingPath:aPath :cell];
我正在将此方法中的路径添加到像这样的单元格
- (void)setClippingPath:(UIBezierPath *)clippingPath : (id )imgView;
{
if (![[imgView layer] mask])
[[imgView layer] setMask:[CAShapeLayer layer]];
[(CAShapeLayer*) [[imgView layer] mask] setPath:[clippingPath CGPath]];
}
但是每次都会添加不同的宽度。在集合视图中,每次重新加载时,单元格之间的间距都会发生变化。我还在-13之间添加了行间距,以便在单元格之间正确获取幻灯片,如
`- (CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout minimumLineSpacingForSectionAtIndex:(NSInteger)section
{
return -13.0;
}`
有人知道为什么每次细胞之间的间距会有所不同吗?