Permalink
Browse files

added readme

  • Loading branch information...
1 parent aab2545 commit 82ad8e98fe96d71012dfb39313cf847e1f1ece74 bryce redd committed Feb 19, 2013
@@ -27,7 +27,7 @@ - (void)viewDidLoad {
RFQuiltLayout* layout = (id)[self.collectionView collectionViewLayout];
layout.direction = UICollectionViewScrollDirectionVertical;
- layout.blockPixels = CGSizeMake(60, 60);
+ layout.blockPixels = CGSizeMake(100, 100);
[self.collectionView reloadData];
}
@@ -66,8 +66,6 @@ - (NSInteger)collectionView:(UICollectionView *)view numberOfItemsInSection:(NSI
- (UICollectionViewCell *)collectionView:(UICollectionView *)cv cellForItemAtIndexPath:(NSIndexPath *)indexPath {
UICollectionViewCell *cell = [cv dequeueReusableCellWithReuseIdentifier:@"cell" forIndexPath:indexPath];
- cell.layer.borderColor = [UIColor blackColor].CGColor;
- cell.layer.borderWidth = 10.f;
cell.backgroundColor = [self colorForNumber:self.numbers[indexPath.row]];
UILabel* label = (id)[cell viewWithTag:5];
@@ -103,5 +101,9 @@ - (CGSize) blockSizeForItemAtIndexPath:(NSIndexPath *)indexPath {
return CGSizeMake(1, 1);
}
+- (UIEdgeInsets)insetsForItemAtIndexPath:(NSIndexPath *)indexPath {
+ return UIEdgeInsetsMake(2, 2, 2, 2);
+}
+
@end
View
@@ -0,0 +1,37 @@
+RFQUILTLAYOUT
+=============
+
+RFQuiltLayout is a [UICollectionViewLayout](http://developer.apple.com/library/ios/#documentation/UIKit/Reference/UICollectionViewLayout_class/Reference/Reference.html#//apple_ref/occ/cl/UICollectionViewLayout) subclass, used as the layout object of [UICollectionView](http://developer.apple.com/library/ios/#documentation/UIKit/Reference/UICollectionView_class/Reference/Reference.html).
+
+![Demo 1](http://i.imgur.com/BcQhwzR.png)
+![Demo 2](http://i.imgur.com/hoBWCis.png)
+
+
+Installation
+------------
+
+Add the layout as the subclass of your UICollectionViewLayout.
+
+![Subclass the layout](http://i.imgur.com/vlqqKjP.png)
+
+
+*Make sure you set the delegate of the flow layout*
+
+ - (void) viewDidLoad {
+ // ...
+
+ RFQuiltLayout* layout = (id)[self.collectionView collectionViewLayout];
+ layout.direction = UICollectionViewScrollDirectionVertical;
+ layout.blockPixels = CGSizeMake(100, 100);
+ }
+
+ - (CGSize) blockSizeForItemAtIndexPath:(NSIndexPath *)indexPath {
+ if (indexPath.row % 2 == 0)
+ return CGSizeMake(2, 1);
+
+ return CGSizeMake(1, 2);
+ }
+
+(Note: all delegate methods and properties are optional)
+
+
@@ -23,6 +23,6 @@
// only use this if you don't have more than 1000ish items.
// this will give you the correct size from the start and
// improve scrolling speed, at the cost of time at the beginning
-@property (nonatomic) BOOL predrawEverything;
+@property (nonatomic) BOOL prelayoutEverything;
@end

0 comments on commit 82ad8e9

Please sign in to comment.