iOS:在用户拖拽时拉伸/调整UITableView标头的大小? [英] iOS: Stretching / Resizing UITableView Header As The User Drags Down?
问题描述
使用storyboard,我已将 imageView
作为我的 tableView的
headerView
在 ViewController
里面。
Using storyboard, I have placed an imageView
as my tableView's
headerView
inside a ViewController
.
这就是我的故事板设置方式:
This is how my storyboard is set up:
根据用户正在查看的数据, viewController
将显示或隐藏 headerView
。我的问题是,当 headerView
可见且用户拖拽 tableView
时,怎么能我有 imageView
坚持 navigationBar
和 tableView
当它调整大小以覆盖其间的空间?
Depending on what data the user is viewing, the viewController
will either show or hide the headerView
. My question is, that when the headerView
is visible and the user drags down on the tableView
, how can I have the imageView
stick to both the navigationBar
and the tableView
as it resizes to cover the space in between?
这就是它目前所做的:
但这是我想要的是:
任何帮助将不胜感激。我看过视差库,但是没有人支持sectionTitles,我也不一定会选择视差效果。当用户向上滚动时,我希望它弹回到regularView而不是隐藏headerView。谢谢!
Any help would be greatly appreciated. I've looked at parallax libraries, but none support sectionTitles, and I'm not necessarily going for the parallax effect either. When the user scrolls up, I want it to bounce back to the regularView and not hide the headerView. Thanks!
更新:
我已按照Dany发布的建议进行操作并完成了以下
:
UPDATE:
I have followed the advice posted by Dany below and have done the following:
-(void)scrollViewDidScroll:(UIScrollView*)scrollView {
CGRect initialFrame = CGRectMake(0, 0, 320, 160);
if (scrollView.contentOffset.y < 0) {
initialFrame.size.height =! scrollView.contentOffset.y;
childHeaderView.frame = initialFrame;
} }
childHeaderView是一个imageView,出于某种原因,当我向下拖动时,
图像向上移动(就像在navBar后面的一半)并且不返回。任何建议将是
非常感谢!!谢谢!
childHeaderView is an imageView and for some reason when I drag down, the image moves up (like half of it behind the navBar) and doesn't return. Any advice would be greatly appreciated!! Thanks!
推荐答案
我最近发布了一篇关于使用可能有帮助的约束来实现此目的的博客文章,事实证明这很直接。
I recently posted a blog post about accomplishing this using constraints which might help, turns out it was quite straight forward.
这篇关于iOS:在用户拖拽时拉伸/调整UITableView标头的大小?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!