99import Foundation
1010import UIKit
1111
12- @objc protocol CHTCollectionViewDelegateWaterfallLayout : UICollectionViewDelegate {
12+ @objc public protocol CHTCollectionViewDelegateWaterfallLayout : UICollectionViewDelegate {
1313
1414 func collectionView ( collectionView: UICollectionView , layout collectionViewLayout: UICollectionViewLayout ,
1515 sizeForItemAtIndexPath indexPath: NSIndexPath ) -> CGSize
@@ -30,68 +30,67 @@ import UIKit
3030 columnCountForSection section: NSInteger ) -> NSInteger
3131}
3232
33- enum CHTCollectionViewWaterfallLayoutItemRenderDirection : NSInteger {
33+ public enum CHTCollectionViewWaterfallLayoutItemRenderDirection : NSInteger {
3434 case CHTCollectionViewWaterfallLayoutItemRenderDirectionShortestFirst
3535 case CHTCollectionViewWaterfallLayoutItemRenderDirectionLeftToRight
3636 case CHTCollectionViewWaterfallLayoutItemRenderDirectionRightToLeft
3737}
3838
39- class CHTCollectionViewWaterfallLayout : UICollectionViewLayout {
39+ public class CHTCollectionViewWaterfallLayout : UICollectionViewLayout {
4040 let CHTCollectionElementKindSectionHeader = " CHTCollectionElementKindSectionHeader "
4141 let CHTCollectionElementKindSectionFooter = " CHTCollectionElementKindSectionFooter "
4242
43- var columnCount : NSInteger {
43+ public var columnCount : NSInteger {
4444 didSet{
4545 invalidateLayout ( )
4646 } }
4747
48- var minimumColumnSpacing : CGFloat {
48+ public var minimumColumnSpacing : CGFloat {
4949 didSet{
5050 invalidateLayout ( )
5151 } }
5252
53- var minimumInteritemSpacing : CGFloat {
53+ public var minimumInteritemSpacing : CGFloat {
5454 didSet{
5555 invalidateLayout ( )
5656 } }
5757
58- var headerHeight : CGFloat {
58+ public var headerHeight : CGFloat {
5959 didSet{
6060 invalidateLayout ( )
6161 } }
6262
63- var footerHeight : CGFloat {
63+ public var footerHeight : CGFloat {
6464 didSet{
6565 invalidateLayout ( )
6666 } }
6767
68- var sectionInset : UIEdgeInsets {
68+ public var sectionInset : UIEdgeInsets {
6969 didSet{
7070 invalidateLayout ( )
7171 } }
7272
7373
74- var itemRenderDirection : CHTCollectionViewWaterfallLayoutItemRenderDirection {
74+ public var itemRenderDirection : CHTCollectionViewWaterfallLayoutItemRenderDirection {
7575 didSet{
7676 invalidateLayout ( )
7777 } }
7878
79-
80- // private property and method above.
81- weak var delegate : CHTCollectionViewDelegateWaterfallLayout ? {
79+ public weak var delegate : CHTCollectionViewDelegateWaterfallLayout ? {
8280 get {
8381 return self . collectionView!. delegate as? CHTCollectionViewDelegateWaterfallLayout
8482 }
8583 }
86- var columnHeights : NSMutableArray
87- var sectionItemAttributes : NSMutableArray
88- var allItemAttributes : NSMutableArray
89- var headersAttributes : NSMutableDictionary
90- var footersAttributes : NSMutableDictionary
91- var unionRects : NSMutableArray
92- let unionSize = 20
9384
94- override init ( ) {
85+ private var columnHeights : NSMutableArray
86+ private var sectionItemAttributes : NSMutableArray
87+ private var allItemAttributes : NSMutableArray
88+ private var headersAttributes : NSMutableDictionary
89+ private var footersAttributes : NSMutableDictionary
90+ private var unionRects : NSMutableArray
91+ private let unionSize = 20
92+
93+ override public init ( ) {
9594 self . headerHeight = 0.0
9695 self . footerHeight = 0.0
9796 self . columnCount = 2
@@ -111,7 +110,7 @@ class CHTCollectionViewWaterfallLayout : UICollectionViewLayout{
111110 super. init ( )
112111 }
113112
114- required init ? ( coder aDecoder: NSCoder ) {
113+ required public init ? ( coder aDecoder: NSCoder ) {
115114 fatalError ( " init(coder:) has not been implemented " )
116115 }
117116
@@ -136,7 +135,7 @@ class CHTCollectionViewWaterfallLayout : UICollectionViewLayout{
136135 return floor ( ( width - ( spaceColumCount*self. minimumColumnSpacing) ) / CGFloat( columnCount) )
137136 }
138137
139- override func prepareLayout( ) {
138+ override public func prepareLayout( ) {
140139 super. prepareLayout ( )
141140
142141 let numberOfSections = self . collectionView!. numberOfSections ( )
@@ -280,7 +279,7 @@ class CHTCollectionViewWaterfallLayout : UICollectionViewLayout{
280279 }
281280 }
282281
283- override func collectionViewContentSize( ) -> CGSize {
282+ override public func collectionViewContentSize( ) -> CGSize {
284283 let numberOfSections = self . collectionView!. numberOfSections ( )
285284 if numberOfSections == 0 {
286285 return CGSizeZero
@@ -292,7 +291,7 @@ class CHTCollectionViewWaterfallLayout : UICollectionViewLayout{
292291 return contentSize
293292 }
294293
295- override func layoutAttributesForItemAtIndexPath( indexPath: NSIndexPath ) -> UICollectionViewLayoutAttributes ? {
294+ override public func layoutAttributesForItemAtIndexPath( indexPath: NSIndexPath ) -> UICollectionViewLayoutAttributes ? {
296295 if indexPath. section >= self . sectionItemAttributes. count {
297296 return nil
298297 }
@@ -304,7 +303,7 @@ class CHTCollectionViewWaterfallLayout : UICollectionViewLayout{
304303 return list. objectAtIndex ( indexPath. item) as? UICollectionViewLayoutAttributes
305304 }
306305
307- override func layoutAttributesForSupplementaryViewOfKind( elementKind: String , atIndexPath indexPath: NSIndexPath ) -> UICollectionViewLayoutAttributes {
306+ override public func layoutAttributesForSupplementaryViewOfKind( elementKind: String , atIndexPath indexPath: NSIndexPath ) -> UICollectionViewLayoutAttributes {
308307 var attribute = UICollectionViewLayoutAttributes ( )
309308 if elementKind == CHTCollectionElementKindSectionHeader{
310309 attribute = self . headersAttributes. objectForKey ( indexPath. section) as! UICollectionViewLayoutAttributes
@@ -314,7 +313,7 @@ class CHTCollectionViewWaterfallLayout : UICollectionViewLayout{
314313 return attribute
315314 }
316315
317- override func layoutAttributesForElementsInRect( rect: CGRect ) -> [ UICollectionViewLayoutAttributes ] ? {
316+ override public func layoutAttributesForElementsInRect( rect: CGRect ) -> [ UICollectionViewLayoutAttributes ] ? {
318317 var begin = 0 , end = self . unionRects. count
319318 let attrs = NSMutableArray ( )
320319
@@ -344,7 +343,7 @@ class CHTCollectionViewWaterfallLayout : UICollectionViewLayout{
344343 return NSArray ( array: attrs) as? [ UICollectionViewLayoutAttributes ]
345344 }
346345
347- override func shouldInvalidateLayoutForBoundsChange ( newBounds : CGRect ) -> Bool {
346+ override public func shouldInvalidateLayoutForBoundsChange ( newBounds : CGRect ) -> Bool {
348347 let oldBounds = self . collectionView!. bounds
349348 if CGRectGetWidth ( newBounds) != CGRectGetWidth ( oldBounds) {
350349 return true
0 commit comments