【发布时间】:2014-01-09 23:11:11
【问题描述】:
从我问过的previous SO question 开始,我试图为UICollectionView(在示例中为yellowBox)的高度变化设置动画。通过使用以下代码修改集合视图上的自动布局约束来触发高度变化:
- (IBAction)expandYellowBox:(id)sender {
[UIView animateWithDuration:0.5
animations:^{
self.yellowBoxHeightConstraint.constant += 50;
[self.view layoutIfNeeded];
}];
}
但是,当我调用 [self.view layoutIfNeeded] 时,这会导致集合视图被重新加载,因此它对用户可见。但是,我不希望重新加载集合视图,而只是为其高度变化设置动画。有什么方法可以避免-layoutIfNeeded 重新加载集合视图,或者另一种方法来动画约束高度变化,它不会调用具有重新加载集合视图副作用的方法?
【问题讨论】:
标签: ios cocoa-touch uicollectionview autolayout