iOS:在用户向下拖动时拉伸/调整 UITableView 标题的

iOS: Stretching / Resizing UITableView Header As The User Drags Down?(iOS:在用户向下拖动时拉伸/调整 UITableView 标题的大小?)
本文介绍了iOS:在用户向下拖动时拉伸/调整 UITableView 标题的大小?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用故事板,我在 ViewController 中放置了一个 imageView 作为我的 tableView 的 headerView.

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 上向下拖动时,我怎样才能拥有 imageViewnavigationBartableView 调整大小以覆盖其间的空间?

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,而且我也不一定要使用视差效果.当用户向上滚动时,我希望它反弹回常规视图而不是隐藏 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,由于某种原因,当我向下拖动时,图像向上移动(就像导航栏后面的一半)并且不会返回.任何建议都是非常感激!!谢谢!

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.

这里是链接:使用约束在 UIScrollView 上创建视差效果

这篇关于iOS:在用户向下拖动时拉伸/调整 UITableView 标题的大小?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

Why local notification is not firing for UNCalendarNotificationTrigger(为什么没有为UNCalendarNotificationTrigger触发本地通知)
iOS VoiceOver functionality changes with Bundle Identifier(IOS画外音功能随捆绑包标识符而变化)
tabbar middle tab out of tabbar corner(选项卡栏中间的选项卡角外)
Pushing UIViewController above UITabBar(将UIView控制器推送到UITabBar上方)
How can I sync two flatList scroll position in react native(如何在本机Reaction中同步两个平面列表滚动位置)
Get an event when UIBarButtonItem menu is displayed(显示UIBarButtonItem菜单时获取事件)