我试图在集合视图滚动时为桌面高度设置动画。我从scrollViewWillBeginDragging调用动画函数。然后我执行一个动画块:UITableView的动画高度
func scrollViewWillBeginDragging(scrollView: UIScrollView) {
if expanded == false && scrollView == IBcalendarCollectionView {
expanded = true
expandCollectionView()
}
}
func expandCollectionView() {
let screenSize: CGRect = UIScreen.mainScreen().bounds
UIView.animateWithDuration(3, delay: 0, options: UIViewAnimationOptions.TransitionNone, animations: {() -> Void in
self.IBcalendarTableView.frame = CGRectMake(self.IBcalendarTableView.frame.origin.x, screenSize.height/2, self.IBcalendarTableView.frame.width, screenSize.height/2)
}) { (success) -> Void in
print(self.IBcalendarTableView.frame.origin.y)
}
}
发生什么事是TableView动画到状态栏,然后返回到它的原始位置。我想让它动画缩小到屏幕尺寸的一半。动画块只执行一次,因为我在调用动画函数时设置了布尔值。
很高兴你能得到答案。 – dsieczko