我试图在我的表格 View 中下推部分标题,使其与部分中的第一个单元格重叠,类似于个人资料图片在左侧 linkedin 应用程序中的显示方式:
因此,如果白色 View 与个人资料图片重叠是该部分的第一行,个人资料图片是部分标题。
我试过将框架的 x 坐标更改为负值并调整标题的大小,但都无济于事。
最佳答案
我刚刚在 LinkedIn 应用程序中查看个人资料 View ,我想如果我要构建类似的东西,我会把所有个人资料信息放在 tableHeaderView 中。因此 header 将包含以下内容:
- UIImageView(背景图片)
- UIView(包含配置文件 信息)
- UIImageView(用户个人资料图片)
由于 UITableView 是 UIScrollView 的子类,您可以使用委托(delegate)方法 scrollViewDidScroll 为背景图像设置动画。然后,您可以在 tableview 滚动时调整背景图像的位置
@property (weak, nonatomic) IBOutlet UIImageView *backgroundImage;
- (void)scrollViewDidScroll:(UIScrollView *)scrollView {
// 64 is the height of the navigation bar.
// 110 is the maximum distance I want to move the image down before it starts to move with the table.
CGFloat offset = MIN(scrollView.contentOffset.y + 64, 110);
self.backgroundImage.transform = CGAffineTransformMakeTranslation(0, offset);
}
关于ios - 在 UITableview 重叠单元格中制作节标题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46228098/