[英]How to animate UITableView section footer
我正在嘗試為UITableView節的頁腳設置動畫。 我嘗試了以下代碼:
- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section {
CustomView *footer = [[CustomView alloc]initWithFrame:CGRectZero
labelText:@"I am a label in a footer"];
footer.label.alpha = 0.0f;
[UIView animateWithDuration:5.0f
delay:0.0f
options:UIViewAnimationOptionCurveLinear
animations:^{
footer.label.alpha = 1.0f;
}
completion:nil];
return footer;
}
但是頁腳顯示時沒有動畫。 為UITableView節頁腳設置動畫的正確方法是什么? 我相信有可能,但找不到答案。
嘗試在tableView:willDisplayFooterView:forSection:
方法中制作動畫。 在您使用的方法中,視圖尚未插入視圖層次結構中(因此不在窗口中),因此動畫實際上不會做任何事情(無論如何將其插入視圖中都將被取消)。 -willDisplay *變量確實是您應該在其中配置可見UI屬性的位置,因為它那時應該位於視圖層次結構中,並且應該設置UIAppearance值之類的東西,以便以后不會被覆蓋。
您通常可以通過在cellForRowAtIndexPath:方法(在這種情況下為viewForFooter)中配置屬性來擺脫困境,但並非總是如此-絕對是動畫。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.