转载学习:tabbleView顶部图片的拉伸效果,
_heroBigImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"hero_bg.jpg"]]; _heroBigImageView.frame = CGRectMake(0, -150, 320, 150);
//还要设置
contentMode = UIViewContentModeScaleAspectFill;
.clipsToBounds = YES;
[_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; } } }