gpt4 book ai didi

ios - UITableView - BeginUpdates/EndUpdates 动画设置

转载 作者:行者123 更新时间:2023-12-01 18:59:29 30 4
gpt4 key购买 nike

我正在构建一个 UITableView选择时,单元格会“滑出”下方的附加 View 。为此,我使用 [tableview beginUpdates] 为表格 View 中的行高设置了动画。和 [tableView endUpdates]然后我正在为滑动 View 设置动画,使其与该动画一起翻译,使其看起来像是被揭开的。我使用的动画效果很好,但与行高的移动方式略有不同。

例如,这是我的单元格。通常,只显示白色部分(由于突出显示为蓝色),但如果您选择一行,灰色 View 会从底部滑出,就像该行的操作菜单一样,带有几个按钮:

enter image description here

我想知道的是:table view的BeginUpdates默认使用的动画设置是什么?/EndUpdates方法,或者如果那是未知的,我是否可以将它们设置为自定义,以便我的行高和滑动 View 的动画完全相同?

tableView方法:

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
if ([[tableView indexPathForSelectedRow] isEqual:indexPath])
return CellHeightAlternate;
return CellHeightNormal;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
SlideOutViewTableViewCell *newCell = (SlideOutViewTableViewCell *)[tableView cellForRowAtIndexPath:indexPath];

[tableView beginUpdates];
[tableView endUpdates];

[newCell showView];
}

SlideOutTableViewCell showView 方法:
- (void)showView{
[self.slideoutView setFrame:CGRectMake(self.slideoutView.frame.origin.x, 40, self.slideoutView.frame.size.width, self.slideoutView.frame.size.height)];
[UIView animateWithDuration:.25 animations:^{
[self.slideoutView setFrame:CGRectMake(self.slideoutView.frame.origin.x, 70, self.slideoutView.frame.size.width, self.slideoutView.frame.size.height)];

}];
}

最佳答案

所以我通过反复试验找到了答案:

表格 View 更改行高的动画(来自 [tableview beginUpdates][tableView endUpdates] 方法)是持续时间为 0.3 秒的线性动画(无动画效果)。

关于ios - UITableView - BeginUpdates/EndUpdates 动画设置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23748034/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com