supersr--去除tableViewHeader的粘性

这段代码能去除tableViewHeader的粘性

 

const static NSInteger kSectionHeaderHeight = 30;

- (void)scrollViewDidScroll:(UIScrollView *)scrollView

{

    if (scrollView.contentSize.height > self.view.height) {

        if (scrollView.contentOffset.y<=kSectionHeaderHeight&&scrollView.contentOffset.y>=0) {

            scrollView.contentInset = UIEdgeInsetsMake(0, 0, 0, 0);

        } else if (scrollView.contentOffset.y>=kSectionHeaderHeight){

            scrollView.contentInset = UIEdgeInsetsMake(-kSectionHeaderHeight, 0, 0, 0);

        }

    }

}

 

 

//是不是i7.0

#define IOS7_OR_LATER   ( [[[UIDevice currentDevice] systemVersion] compare:@"7.0"] != NSOrderedAscending )

- (void)scrollViewDidScroll:(UIScrollView *)scrollView {

    if (!IOS7_OR_LATER){

        CGFloat sectionHeaderHeight = 53;

        if (scrollView.contentOffset.y<=sectionHeaderHeight&&scrollView.contentOffset.y>=0) {

            scrollView.contentInset = UIEdgeInsetsMake(-scrollView.contentOffset.y, 0, 0, 0);

        } else if (scrollView.contentOffset.y>=sectionHeaderHeight) {

            scrollView.contentInset = UIEdgeInsetsMake(-sectionHeaderHeight, 0, 0, 0);

        }

    }

    

}

posted @ 2015-10-14 15:26  super1250  阅读(321)  评论(0编辑  收藏  举报