美文网首页
tableview的区域随着手指滑动而动态改变

tableview的区域随着手指滑动而动态改变

作者: 骑着毛驴走起来 | 来源:发表于2018-05-04 11:52 被阅读9次

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

    /*

    CGRect frame = scrollView.frame;

    frame.origin.y = frame.origin.y - scrollView.contentOffset.y;

    NSLog(@"scrollView.contentOffset.y = %.2f, frame.origin.y = %.2f, scrollView.bounds.origin.y = %.2f", scrollView.contentOffset.y, frame.origin.y,scrollView.bounds.origin.y);

    // 1.contentOffset.y 向上滑为正 ,向下滑为负; 2.frame.origin.y 为scrollView的原点y坐标,向上滑减小,向下滑增加  3.scrollView.bounds.origin.y 和 contentOffset.y值相同

    */

    CGFloat height = 100 ;//tableView上面的View高度

    CGRectaOriginRect = scrollView.frame;

    aOriginRect.origin.y= aOriginRect.origin.y- scrollView.contentOffset.y;//tableView当前的y坐标

    if(aOriginRect.origin.y<= height+LL_StatusBarAndNavigationBarHeight  && aOriginRect.origin.y>=0){//向上滑,但scrollView没滚动出View

        CGRectaOriginBounds = scrollView.bounds;

        aOriginBounds.origin=CGPointMake(0,0);

        scrollView.bounds= aOriginBounds;

    }

    else if (aOriginRect.origin.y > height+ LL_StatusBarAndNavigationBarHeight ){//向下滑

        aOriginRect.origin.y= height +LL_StatusBarAndNavigationBarHeight;

    }

    else{

        aOriginRect.origin.y=0;//向上滑,且scrollView滚动出View

    }

   CGSizescreenSize = [[UIScreenmainScreen]bounds].size;

    aOriginRect.size.height= screenSize.height- aOriginRect.origin.y;

    scrollView.frame= aOriginRect;

    self.titleView.frame = CGRectMake(self.titleView.frame.origin.x, scrollView.frame.origin.y - height, self.titleView.frame.size.width, self.titleView.frame.size.height);

}

相关文章

网友评论

      本文标题:tableview的区域随着手指滑动而动态改变

      本文链接:https://www.haomeiwen.com/subject/ctldrftx.html