如何在UITableView中为节标题的高度变化设置动画? [英] How to animate the height change of an section header in UITableView?
本文介绍了如何在UITableView中为节标题的高度变化设置动画?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我已经实现了这个方法来返回节标题高度。但是,当该部分的高度发生变化时,它会立即发生而不会产生动画。
I've implemented this method to return the section header height. However, when the height for the section changes, it happens immediately without animation.
是否有动画?
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
if (flatHeader) {
return 50.0f;
} else {
return 100.0f;
}
}
推荐答案
我我不是100%肯定这适用于表头,但它适用于表行,因此值得一试。我有一个实例变量 headerHeight
最初设置为44.0并且我更改为:
I'm not 100% sure this will work for a table header but it works for table rows so it's worth a shot. I have an instance variable headerHeight
initially set to 44.0 and I change it as so:
- (void)changeHeight {
[self.tableView beginUpdates];
headerHeight = 88.0;
[self.tableView endUpdates];
}
在我的代码中,我返回 headerHeight
in heightForRowAtIndexPath
但你可以在 heightForHeaderInSection
中试用:
In my code I return the headerHeight
in heightForRowAtIndexPath
but you can try it in heightForHeaderInSection
:
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
return headerHeight;
}
这篇关于如何在UITableView中为节标题的高度变化设置动画?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文