gpt4 book ai didi

ios - 扩展 UICollectionView header 内容以到达第一个单元格下方

转载 作者:搜寻专家 更新时间:2023-11-01 07:03:29 28 4
gpt4 key购买 nike

下面是我要实现的效果,将header的内容扩展到第一个cell下面。我试图将图像大小设置为大于标题并将 clipsToBounds 设置为 false。但是,图像位于单元格顶部并覆盖它。有没有办法将图像移动到单元格下方?

enter image description here

最佳答案

您可以通过在 willDisplayXXX 方法中设置图层的 zPosition 来实现。

- (void)collectionView:(UICollectionView *)collectionView willDisplaySupplementaryView:(UICollectionReusableView *)view forElementKind:(NSString *)elementKind atIndexPath:(NSIndexPath *)indexPath
{
view.layer.zPosition = 0.0;
}

- (void)collectionView:(UICollectionView *)collectionView willDisplayCell:(UICollectionViewCell *)cell forItemAtIndexPath:(NSIndexPath *)indexPath
{
cell.layer.zPosition = 99 + indexPath.row;
}

同样,您可以使用 willDisplayHeaderViewwillDisplayCell 方法在 UITableView 中完成此操作。基本上,将标题设置为较低的值并将单元格设置为较高的值,它应该将单元格放在标题的前面。

-(void)tableView:(UITableView *)tableView willDisplayHeaderView:(UIView *)view forSection:(NSInteger)section
{
view.layer.zPosition = 0.0;
}

- (void)tableView:(UITableView *)tableView willDisplayCell:(MyCustomCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath
{
cell.layer.zPosition = 99 + indexPath.row;
}

关于ios - 扩展 UICollectionView header 内容以到达第一个单元格下方,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49635847/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com