Alright so I have a UICollectionViewFlowLayout that supports spring-like animations while scrolling similar to the iOS messages app. Anyway, upon converting to Swift 2.0, it seems that UIDynamics have completely changed. I'm trying to convert the following blocks but I just can't seem to figure it out and Apple's documentation is VERY unsupportive here. The following blocks need to be converted still:
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 the error:
"Value of type 'UIDynamicBehavior' has no member 'items' "
Then I have:
override func layoutAttributesForElementsInRect(rect: CGRect) -> [UICollectionViewLayoutAttributes]? {
return self.dynamicAnimator.itemsInRect(rect)
}
which produces the error:
"Cannot convert return expression of type '[UIDynamicItem]' to return type '[UICollectionViewLayoutAttributes]?' "
Any ideas on how I can convert this? I know swift 2 is very new but I can't find ANYTHING online regarding this and like I said, the documentation on UIKitDynamicBehavior is lacking to say the least. Thanks in advance for your help!
To fix the first block issue:
Value of type '
UIDynamicBehavior
' has no member 'items'
let attachmentBehavior:UIAttachmentBehavior = behavior as! UIAttachmentBehavior
To fix the second issue:
Cannot convert return expression of type '
[UIDynamicItem]
' to return type '[UICollectionViewLayoutAttributes]?
'
return self.dynamicAnimator.itemsInRect(rect) as? [UICollectionViewLayoutAttributes]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With