下拉的tableview的头部拉伸效果



1 先把imageview添加在tableview上,注意大小位置,-150
_heroBigImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"hero_bg.jpg"]]; _heroBigImageView.frame = CGRectMake(0, -150, 320, 150); [_tableView addSubview:_heroBigImageView];
2 设置tableview的contentInset,向下移动150
_tableView.contentInset = UIEdgeInsetsMake(150, 0, 0, 0);
3 scrollview的代理,获取contentoffset,然后从新设置imageview的frame
- (void)scrollViewDidScroll:(UIScrollView *)scrollView { //获取当前活动的tableview CGFloat y = scrollView.contentOffset.y; if (scrollView == _tableView) { if (y < -150) { CGRect frame = _heroBigImageView.frame; frame.size.height = - y ; frame.origin.y = y; _heroBigImageView.frame = frame; } } }

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM