【发布时间】:2017-04-25 21:12:26
【问题描述】:
问题可见:http://i.imgur.com/TastPR9.gifv
func animateHeaderResize(height: CGFloat) {
let layout = self.collectionView?.collectionViewLayout as! UICollectionViewFlowLayout;
layout.headerReferenceSize = CGSize(width: UIScreen.main.bounds.width, height: height);
UIView.animate(withDuration: 1, delay: 0, options: .curveEaseOut, animations: {
self.collectionView?.layoutIfNeeded();
}) { (finished) in
//self.loadPosts();
}
}
我正在尝试通过 UICollectionViewLayout 对 UICollectionView 的标题大小进行动画更改。生成的动画有一个奇怪的闪光和拉伸,可能是某个地方触发了交叉溶解过渡。我尝试了许多设置集合视图布局的变体,包括 setCollectionViewLayout(layout:animated:) 和实现 collectionView(_ collectionView: layout:referenceSizeForHeaderInSection section:),但都产生相同的动画。
我注意到在更改集合视图的项目大小时会出现相同的闪烁。也许这是我可以修改的一些默认行为?我必须继承 UICollectionViewFlowLayout 吗?我已经尝试过搜索,但找不到解决方案,如果朝着正确的方向迈出一步,我将不胜感激。
【问题讨论】:
标签: ios iphone swift uicollectionview uicollectionviewlayout