이것은 최적화 된 코드는 아니지만 다음과 같이 시도해 볼 수 있습니다.
-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
return headerHeight;
}
-(void)scrollViewDidScroll:(UIScrollView *)scrollView{
CGFloat maxHeaderHeight = 400;
CGFloat minHeaderHeight = 40;
if (self.lastContentOffset > scrollView.contentOffset.y){
// scrolling down
if(headerHeight < maxHeaderHeight){
headerHeight += scrollView.contentOffset.y;
}
headerHeight = MIN(headerHeight, maxHeaderHeight);
}else if (self.lastContentOffset < scrollView.contentOffset.y){
// scrolling up
if (headerHeight > minHeaderHeight) {
headerHeight -= scrollView.contentOffset.y;
}
headerHeight = MAX(headerHeight, minHeaderHeight);
}
self.lastContentOffset = scrollView.contentOffset.y;
[self.tableView reloadData];
}
가능하면 전체 애니메이션을 보여주는 gif를 게시 할 수 있습니다. 이전 및 이후 이미지를 사용하여 접근 방식을 결정하기가 매우 어렵습니다! 하지만 대부분의 동작은 'UITableViewCell'과 UIView를 사용하여 사용자가 스크롤하는 양에 따라 적절한 애니메이션을 사용하여 복제 할 수 있습니다. – Rikh
높이를 결정하는 코드를 보여줍니다. – iphonic
spotify 앱은 아마도 collectionview를 사용합니다. – Groot