我的 TableView Controller 实现了 viewForHeaderInSection 函数,以自定义字体返回部分标签。
目前我们使用透明背景,但如果单元格开始在标题 View 后面滚动,那看起来就不太好了。
我想为标题 View 绘制一个透明到白色的渐变,但仅限于卡在顶部的 View 。
显然 if(section==0)
是行不通的。
有什么技巧吗?
最佳答案
有时最好在发布到堆栈溢出之前考虑一下。这是我找到的记录解决方案。我希望它对某人有所帮助。
NSArray * visibleIndexes = [tableView indexPathsForVisibleRows];
NSIndexPath * firstVisibleIndex = [visibleIndexes objectAtIndex:0];
if (section == firstVisibleIndex.section) {
// configure the header at the top
}
else {
// configure other headers
}
关于ios - viewForHeaderInSection 绘制背景,但前提是 View 位于屏幕顶部,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7197328/