Ok, so I have a UICollectionViewFlowLayout that supports spring animations while scrolling like an iOS messaging app. In any case, when switching to Swift 2.0, it seems that UIDynamics has completely changed. I am trying to convert the following blocks, but I just can't figure it out, and the Apple documentation here is VERY incompatible. The following blocks still need to be converted:
var noLongerVisibleBehaviors = self.dynamicAnimator.behaviors.filter({behavior in var currentlyVisible = itemsIndexPathsInVisibleRectSet.member(behavior.items![0].indexPath) != nil return !currentlyVisible }) for (index, obj) in noLongerVisibleBehaviors.enumerate() { self.dynamicAnimator.removeBehavior(obj ) self.visibleIndexPathsSet.removeObject(obj.items![0].indexPath) }
Both of these blocks cause an error:
"Value of type" UIDynamicBehavior "does not have elements of the element"
Then I:
override func layoutAttributesForElementsInRect(rect: CGRect) -> [UICollectionViewLayoutAttributes]? { return self.dynamicAnimator.itemsInRect(rect) }
which causes the error:
"Cannot convert the returned expression of type '[UIDynamicItem]' to return the type '[UICollectionViewLayoutAttributes]?'"
Any ideas on how I can convert this? I know that swift 2 is very new, but I can not find ANYTHING on the Internet regarding this and, as I said, the documentation for UIKitDynamicBehavior is at least missing. Thanks in advance for your help!
source share