iOS UITableView上滑吸顶的三种方案

时间:2019-09-09 17:57:28   收藏:0   阅读:749

iOS 中很多时候回碰到上滑吸顶的效果,现在总结了以下三种方案,个人比较推崇第一种

1、 UITableViewStylePlain样式下tableHeaderView和sectionHeader共用。tableHeaderView设置为顶部滚动元素,需要第几组的heder吸顶就直接设置sectionHeader

- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
    return 10;
    
}

- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
    return nil;
    
}

2、设置 UITableView顶部内间距, 将吸顶元素添加在view上 ,滚动过程中变化吸顶元素y值。

3、吸顶元素添加在view上, UITableView顶部和吸顶元素底部相同 ,   滚动过程中变化吸顶元素y值 。 效果不好(因为顶部元素和table高度都在变)

原文:https://www.cnblogs.com/lijianyi/p/11492705.html

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!