我使用自动布局与此布局下面调整大小的UIView与自动布局:当置于具有固定大小的UIView
与帧self.view(0,80,320,488)
的CollectionView与框架(0,0,320,220)
underView与框架(0220320268)
并试图实现这应该调整的动画underView放大其高度,使underView部分覆盖collectionView自下而上的移动。
自动布局强制的,因此我已经创建了一个IBOutlet为underView高度约束我在动画正在调整的2次的高度约束:
NSLog(@"underView height %.2f", self.underView.frame.size.height);
NSLog(@"offset (%.2f, %.2f)", offset.x, offset.y);
heightConstraint.constant += offset.y;
NSLog(@"heightConstraint %.2f", heightConstraint.constant);
[self.underView setNeedsUpdateConstraints];
[UIView animateWithDuration:ANIMATION_DURATION
delay:ANIMATION_DELAY
options:UIViewAnimationOptionCurveEaseOut
animations:^{
[self.underView layoutIfNeeded];
NSLog(@"underView height %.2f", heightConstraint.constant);
} completion:nil];
并在控制台中,我可以看到:
2013-07-30 09:09:37.268 Cal[49611:a0b] underView height 268.00
2013-07-30 09:09:37.268 Cal[49611:a0b] offset (320.00, 144.00)
2013-07-30 09:09:37.269 Cal[49611:a0b] heightConstraint 412.00
2013-07-30 09:09:37.270 Cal[49611:a0b] underView height 412.00
但是调整大小根本不会发生。
这种行为的唯一原因我能想到的是上面的collectionView的高度约束,但由于我不希望集合重新加载,我无法对此操作。
我想知道如何实现具有扩展OVER集合视图的underView?我尝试使用约束优先权,但它没有工作...
谢谢@Maarten,但实际上这并没有什么区别,此外,如果您阅读了关于答案的注释,则链接人员已经确认,持续更新可以很好地避开动画,只留下layoutIfNeeded方法在动画块中。作为一个额外的提示,我也尝试调用[self.view layoutIfNeeded],因为有人指出是需要重新显示布局的超级视图,但没有再改变。 –
你有没有试过在superView上调用'layoutIfNeeded'?我改变了我的答案以反映这一点。 – Maarten
是的,正如我上面所说,self.view是superview。 –