我正在切换两个视图,问题是当我从view1切换到view2时,view2的背景颜色首先出现,然后出现所有子视图,这会导致不必要的闪烁。
问题在于: -
[UIView beginAnimations:@"blabla" context:nil];
[UIView setAnimationDuration:5];
view1.alpha = 1;
[UIView commitAnimations];
首先显示view1背景颜色,然后在约0.3秒后显示其子视图,我该怎么办?
答案 0 :(得分:0)
尝试在动画块之前添加以下代码:
[view1 setNeedsLayout];
[view1 layoutIfNeeded];
// Now all the subviews of view1 are in place
[UIView beginAnimations:@"blabla" context:nil];
[UIView setAnimationDuration:5];
view1.alpha = 1;
[UIView commitAnimations];