如何为UITableView标题视图设置动画 [英] How to animate UITableView header view

查看:112
本文介绍了如何为UITableView标题视图设置动画的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要为tableview标题视图的插入设置动画。我希望表格行在标题视图扩展其框架时向下滑动。

到目前为止,我得到的最好结果是使用以下代码:

I need to animate the insertion of a tableview header view. I want that the table rows to slide down while the header view expands its frame.
So far the best result I got is by using the following code:

[self.tableView beginUpdates];  
[self.tableView setTableHeaderView:self.someHeaderView];  
[self.tableView endUpdates];

这个解决方案的问题是标题本身没有动画,它的框架没有扩展。

The problem with this solution is that the header itself doesn't get animated, its frame doesn't expand.

所以我得到的效果是表格行向下滑动(如我所愿)但是标题视图会立即显示,我希望它能够展开这是带动画的框架。

So the effect I'm getting is that the table rows slide down (as I want) but the header view is immediately shown, and I want it to expand it's frame with animation.

任何想法?

谢谢。

推荐答案

标题框架位于 CGRectZero
并使用动画设置其框架

have the header frame at CGRectZero and set its frame using animation

[self.tableView beginUpdates];  
[self.tableView setTableHeaderView:self.someHeaderView];  

[UIView animateWithDuration:.5f animations:^{
  CGRect theFrame = someBigger.frame;
  someHeaderView.frame = theFrame;
}];

[self.tableView endUpdates];  

这篇关于如何为UITableView标题视图设置动画的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆