清华大佬耗费三个月吐血整理的几百G的资源,免费分享!....>>>
#import "TableViewController.h" @interface TableViewController () { UIView *_headerView; UIImageView *imagee; } @end @implementation TableViewController - (void)viewDidLoad { [super viewDidLoad]; _headerView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, [[UIScreen mainScreen] bounds].size.width, 200)]; UIImage *image = [UIImage imageNamed:@"1"]; imagee = [[UIImageView alloc]initWithFrame:CGRectMake(([[UIScreen mainScreen] bounds].size.width / 2) - 40 , 25, 80, 80)]; imagee.image = image; [_headerView addSubview:imagee]; self.tableView.tableHeaderView = _headerView; } - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated. } - (void)scrollViewDidScroll:(UIScrollView *)scrollView{ CGFloat yOffset = self.tableView.contentOffset.y; //向上偏移量变正 向下偏移量变负 if (yOffset < -64) { CGFloat factor = ABS(yOffset)+200-64; CGRect f = CGRectMake(-([[UIScreen mainScreen] bounds].size.width*factor/200-[[UIScreen mainScreen] bounds].size.width)/2,-ABS(yOffset)+64, [[UIScreen mainScreen] bounds].size.width*factor/200, factor); imagee.frame = f; }else { CGRect f = _headerView.frame; f.origin.y = 0; _headerView.frame = f; imagee.frame = CGRectMake(0, f.origin.y, [[UIScreen mainScreen] bounds].size.width, 200); } } #pragma mark - Table view data source - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { #warning Potentially incomplete method implementation. // Return the number of sections. return 0; } - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { #warning Incomplete method implementation. // Return the number of rows in the section. return 0; }