self.imageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"4.jpg"]];
self.imageView.frame = CGRectMake(0, -200, self.view.frame.size.width, 200);
// 给tableView添加头视图
// 宽是tableview的宽度
// self.tableView.tableHeaderView = self.imageView;
// [self.tableView addSubview:self.imageView];
[self.tableView addSubview:self.imageView];
self.tableView.contentInset = UIEdgeInsetsMake(200, 0, 0, 0);
[_imageView release];
}
#pragma mark tableView的delegate已经签订好scrollview的协议,只要设置好代理人,就可以使用scrollview的协议方法
- (void)scrollViewDidScroll:(UIScrollView *)scrollView
{
// NSLog(@"滑动");
// 获取偏移量
CGFloat y = scrollView.contentOffset.y;
NSLog(@"%g", y);
if (y < 0) {
self.imageView.frame = CGRectMake(0, y, self.view.frame.size.width, -y);
}
}
给头视图添加个伸缩动画
最新推荐文章于 2023-03-14 19:36:35 发布