14
14
@interface WSLWaterFlowLayoutStyleOne ()<UICollectionViewDelegate, UICollectionViewDataSource,WSLWaterFlowLayoutDelegate>
15
15
{
16
16
WSLWaterFlowLayout * _flow;
17
+ NSMutableArray * _array;
17
18
}
18
19
@end
19
20
@@ -25,6 +26,11 @@ - (void)viewDidLoad {
25
26
self.navigationItem .title = [NSString stringWithFormat: @" 样式%d " ,self .flowLayoutStyle];
26
27
self.view .backgroundColor = [UIColor grayColor ];
27
28
29
+ _array = [NSMutableArray array ];
30
+ for (int i = 0 ; i < 2 * 30 ; i++) {
31
+ [_array addObject: @(arc4random ()%200 )];
32
+ }
33
+
28
34
_flow = [[WSLWaterFlowLayout alloc ] init ];
29
35
_flow.delegate = self;
30
36
_flow.flowLayoutStyle = self.flowLayoutStyle ;
@@ -73,11 +79,11 @@ - (NSArray *)proportionsForItem{
73
79
// 返回每个item大小
74
80
- (CGSize )waterFlowLayout : (WSLWaterFlowLayout *)waterFlowLayout sizeForItemAtIndexPath : (NSIndexPath *)indexPath {
75
81
if (waterFlowLayout.flowLayoutStyle == (WSLWaterFlowLayoutStyle)0 ){
76
- return CGSizeMake (0 , arc4random () % 200 );
82
+ return CGSizeMake (0 , [_array[indexPath.section * 10 + indexPath.row] floatValue ] );
77
83
}else if (waterFlowLayout.flowLayoutStyle == (WSLWaterFlowLayoutStyle)1 ){
78
- return CGSizeMake (arc4random () % 200 , 0 );
84
+ return CGSizeMake ([_array[indexPath.section * 10 + indexPath.row] floatValue ] , 0 );
79
85
}else if (waterFlowLayout.flowLayoutStyle == (WSLWaterFlowLayoutStyle)2 ){
80
- return CGSizeMake (arc4random () % 200 , 100 );
86
+ return CGSizeMake ([_array[indexPath.section * 10 + indexPath.row] floatValue ] , 100 );
81
87
}else if (waterFlowLayout.flowLayoutStyle == (WSLWaterFlowLayoutStyle)3 ){
82
88
// 每一个最小的正方形单元格的边长
83
89
CGFloat average = (self.view .frame .size .width - [self edgeInsetInWaterFlowLayout: waterFlowLayout].left * 2 - 3 * [self columnMarginInWaterFlowLayout: waterFlowLayout])/4.0 ;
@@ -130,7 +136,7 @@ - (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView
130
136
if (_flow.flowLayoutStyle == (WSLWaterFlowLayoutStyle)3 ){
131
137
return 1 ;
132
138
}
133
- return 3 ;
139
+ return _array. count / 10 ;
134
140
}
135
141
136
142
// 组内成员个数
0 commit comments