brightec / CustomCollectionViewLayout

Custom layout for a collection view using horizontal and vertical scrolling with sticky rows and columns
MIT License
519 stars 123 forks source link

Please update to the Swift2.0 #5

Closed Fight closed 8 years ago

Alphonse-Indpro commented 8 years ago

Try Updating 'layoutAttributesForElementsInRect' in swift 2.0 referred from http://stackoverflow.com/questions/32291135/custom-uicollectionviewlayouts-layoutattributesforelementsinrect-does-not-overr

override func layoutAttributesForElementsInRect(rect: CGRect) -> [UICollectionViewLayoutAttributes]? {

    var attributes = [UICollectionViewLayoutAttributes]()
    if self.itemAttributes != nil {
    for section in self.itemAttributes {

        let filteredArray  =  section.filteredArrayUsingPredicate(

            NSPredicate(block: { (evaluatedObject, bindings) -> Bool in
                return CGRectIntersectsRect(rect, evaluatedObject.frame)
            })
            ) as! [UICollectionViewLayoutAttributes]

        attributes.appendContentsOf(filteredArray)

        }
    }

    return attributes
}
cameroncooke commented 8 years ago

I you branch the code, make the changes you require and issue a pull request I'll look to merging this back in.