Preventing UICollectionViewCell animated appearance when presenting UICollectionView

前端 未结 2 1946
孤独总比滥情好
孤独总比滥情好 2020-12-30 13:38

When a user does some action, I need to pull a UICollectionView from the bottom up to a certain height. Since that new state is totally optional, the collection

2条回答
  •  萌比男神i
    2020-12-30 13:51

    I've been in this problem for around 3 days and finally got a solution. Simply I added the animation block to be called after a very tiny timer

    UIView.animateWithDuration(0.5, delay: 0, usingSpringWithDamping: 0.5, initialSpringVelocity: 7 , options: .CurveEaseInOut, animations: {
                self.view.layoutIfNeeded()
            }){ _ in}
    

    will be

    let delayTime = dispatch_time(DISPATCH_TIME_NOW, Int64(0.1 * Double(NSEC_PER_SEC)))
        dispatch_after(delayTime, dispatch_get_main_queue()) {
            self.changeConstraint()
        }
    
    private func changeConstraint(){
    
            UIView.animateWithDuration(0.5, delay: 0, usingSpringWithDamping: 0.5, initialSpringVelocity: 7 , options: .CurveEaseInOut, animations: {
                self.view.layoutIfNeeded()
            }){ _ in}
    }
    

    See the magic :)

提交回复
热议问题