├── MONUniformFlowLayout-Screenshot.png
├── MONUniformFlowLayoutSample.xcodeproj
├── project.xcworkspace
│ └── contents.xcworkspacedata
└── project.pbxproj
├── MONUniformFlowLayoutSample
├── CollectionViewCell.m
├── CollectionFooterView.m
├── CollectionHeaderView.m
├── CollectionViewCell.h
├── InputViewController.h
├── CollectionFooterView.h
├── CollectionHeaderView.h
├── ViewController.h
├── AppDelegate.h
├── main.m
├── Images.xcassets
│ └── AppIcon.appiconset
│ │ └── Contents.json
├── Info.plist
├── default.json
├── AppDelegate.m
├── InputViewController.m
├── Base.lproj
│ └── LaunchScreen.xib
└── ViewController.m
├── .gitignore
├── MONUniformFlowLayout.podspec
├── MONUniformFlowLayoutSampleTests
├── Info.plist
└── Dummy.m
├── LICENSE
├── README.md
└── MONUniformFlowLayout
├── MONUniformFlowLayout.h
└── MONUniformFlowLayout.m
/MONUniformFlowLayout-Screenshot.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mownier/MONUniformFlowLayout/HEAD/MONUniformFlowLayout-Screenshot.png
--------------------------------------------------------------------------------
/MONUniformFlowLayoutSample.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/MONUniformFlowLayoutSample/CollectionViewCell.m:
--------------------------------------------------------------------------------
1 | //
2 | // CollectionViewCell.m
3 | // CollectionSample
4 | //
5 | // Created by mownier on 12/2/14.
6 | // Copyright (c) 2014 mownier. All rights reserved.
7 | //
8 |
9 | #import "CollectionViewCell.h"
10 |
11 | @implementation CollectionViewCell
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/MONUniformFlowLayoutSample/CollectionFooterView.m:
--------------------------------------------------------------------------------
1 | //
2 | // CollectionFooterView.m
3 | // CollectionSample
4 | //
5 | // Created by mownier on 12/5/14.
6 | // Copyright (c) 2014 mownier. All rights reserved.
7 | //
8 |
9 | #import "CollectionFooterView.h"
10 |
11 | @implementation CollectionFooterView
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/MONUniformFlowLayoutSample/CollectionHeaderView.m:
--------------------------------------------------------------------------------
1 | //
2 | // CollectionHeaderView.m
3 | // CollectionSample
4 | //
5 | // Created by mownier on 12/3/14.
6 | // Copyright (c) 2014 mownier. All rights reserved.
7 | //
8 |
9 | #import "CollectionHeaderView.h"
10 |
11 | @implementation CollectionHeaderView
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/MONUniformFlowLayoutSample/CollectionViewCell.h:
--------------------------------------------------------------------------------
1 | //
2 | // CollectionViewCell.h
3 | // CollectionSample
4 | //
5 | // Created by mownier on 12/2/14.
6 | // Copyright (c) 2014 mownier. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface CollectionViewCell : UICollectionViewCell
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/MONUniformFlowLayoutSample/InputViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // InputViewController.h
3 | // CollectionSample
4 | //
5 | // Created by mownier on 12/10/14.
6 | // Copyright (c) 2014 mownier. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface InputViewController : UIViewController
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/MONUniformFlowLayoutSample/CollectionFooterView.h:
--------------------------------------------------------------------------------
1 | //
2 | // CollectionFooterView.h
3 | // CollectionSample
4 | //
5 | // Created by mownier on 12/5/14.
6 | // Copyright (c) 2014 mownier. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface CollectionFooterView : UICollectionReusableView
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/MONUniformFlowLayoutSample/CollectionHeaderView.h:
--------------------------------------------------------------------------------
1 | //
2 | // CollectionHeaderView.h
3 | // CollectionSample
4 | //
5 | // Created by mownier on 12/3/14.
6 | // Copyright (c) 2014 mownier. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface CollectionHeaderView : UICollectionReusableView
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # OS X
2 | .DS_Store
3 |
4 | # Xcode
5 | build/
6 | *.pbxuser
7 | !default.pbxuser
8 | *.mode1v3
9 | !default.mode1v3
10 | *.mode2v3
11 | !default.mode2v3
12 | *.perspectivev3
13 | !default.perspectivev3
14 | xcuserdata
15 | *.xccheckout
16 | profile
17 | *.moved-aside
18 | DerivedData
19 | *.hmap
20 | *.ipa
21 |
22 | # CocoaPods
23 | Pods
24 |
25 |
--------------------------------------------------------------------------------
/MONUniformFlowLayoutSample/ViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // ViewController.h
3 | // CollectionSample
4 | //
5 | // Created by mownier on 12/2/14.
6 | // Copyright (c) 2014 mownier. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface ViewController : UIViewController
12 |
13 | @property (copy, nonatomic) NSDictionary *inputInfo;
14 |
15 | @end
16 |
17 |
--------------------------------------------------------------------------------
/MONUniformFlowLayoutSample/AppDelegate.h:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.h
3 | // CollectionSample
4 | //
5 | // Created by mownier on 12/2/14.
6 | // Copyright (c) 2014 mownier. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface AppDelegate : UIResponder
12 |
13 | @property (strong, nonatomic) UIWindow *window;
14 |
15 |
16 | @end
17 |
18 |
--------------------------------------------------------------------------------
/MONUniformFlowLayoutSample/main.m:
--------------------------------------------------------------------------------
1 | //
2 | // main.m
3 | // CollectionSample
4 | //
5 | // Created by mownier on 12/2/14.
6 | // Copyright (c) 2014 mownier. All rights reserved.
7 | //
8 |
9 | #import
10 | #import "AppDelegate.h"
11 |
12 | int main(int argc, char * argv[]) {
13 | @autoreleasepool {
14 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/MONUniformFlowLayout.podspec:
--------------------------------------------------------------------------------
1 | Pod::Spec.new do |s|
2 | s.name = 'MONUniformFlowLayout'
3 | s.version = '0.0.1'
4 | s.summary = 'A simple flow layout the handles the arrangement of the items in a collection view uniformly for a particular section.'
5 | s.platform = :ios, '7.0'
6 | s.license = { :type => 'MIT', :file => 'LICENSE' }
7 | s.homepage = 'https://github.com/mownier/MONUniformFlowLayout'
8 | s.author = { 'Mounir Ybanez' => 'rinuom91@gmail.com' }
9 | s.source = { :git =>'https://github.com/mownier/MONUniformFlowLayout.git', :tag => s.version.to_s }
10 | s.source_files = 'MONUniformFlowLayout/*.{h,m}'
11 | s.requires_arc = true
12 | end
13 |
--------------------------------------------------------------------------------
/MONUniformFlowLayoutSample/Images.xcassets/AppIcon.appiconset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "iphone",
5 | "size" : "29x29",
6 | "scale" : "2x"
7 | },
8 | {
9 | "idiom" : "iphone",
10 | "size" : "29x29",
11 | "scale" : "3x"
12 | },
13 | {
14 | "idiom" : "iphone",
15 | "size" : "40x40",
16 | "scale" : "2x"
17 | },
18 | {
19 | "idiom" : "iphone",
20 | "size" : "40x40",
21 | "scale" : "3x"
22 | },
23 | {
24 | "idiom" : "iphone",
25 | "size" : "60x60",
26 | "scale" : "2x"
27 | },
28 | {
29 | "idiom" : "iphone",
30 | "size" : "60x60",
31 | "scale" : "3x"
32 | }
33 | ],
34 | "info" : {
35 | "version" : 1,
36 | "author" : "xcode"
37 | }
38 | }
--------------------------------------------------------------------------------
/MONUniformFlowLayoutSampleTests/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIdentifier
10 | com.mownier.$(PRODUCT_NAME:rfc1034identifier)
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundleName
14 | $(PRODUCT_NAME)
15 | CFBundlePackageType
16 | BNDL
17 | CFBundleShortVersionString
18 | 1.0
19 | CFBundleSignature
20 | ????
21 | CFBundleVersion
22 | 1
23 |
24 |
25 |
--------------------------------------------------------------------------------
/MONUniformFlowLayoutSampleTests/Dummy.m:
--------------------------------------------------------------------------------
1 | //
2 | // Dummy.m
3 | // MONUniformFlowLayoutSample
4 | //
5 | // Created by mownier on 12/10/14.
6 | // Copyright (c) 2014 mownier. All rights reserved.
7 | //
8 |
9 | #import
10 | #import
11 |
12 | @interface Dummy : XCTestCase
13 |
14 | @end
15 |
16 | @implementation Dummy
17 |
18 | - (void)setUp {
19 | [super setUp];
20 | // Put setup code here. This method is called before the invocation of each test method in the class.
21 | }
22 |
23 | - (void)tearDown {
24 | // Put teardown code here. This method is called after the invocation of each test method in the class.
25 | [super tearDown];
26 | }
27 |
28 | - (void)testExample {
29 | // This is an example of a functional test case.
30 | XCTAssert(YES, @"Pass");
31 | }
32 |
33 | - (void)testPerformanceExample {
34 | // This is an example of a performance test case.
35 | [self measureBlock:^{
36 | // Put the code you want to measure the time of here.
37 | }];
38 | }
39 |
40 | @end
41 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2014 mownier
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
23 |
--------------------------------------------------------------------------------
/MONUniformFlowLayoutSample/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIdentifier
10 | com.mownier.$(PRODUCT_NAME:rfc1034identifier)
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundleName
14 | $(PRODUCT_NAME)
15 | CFBundlePackageType
16 | APPL
17 | CFBundleShortVersionString
18 | 1.0
19 | CFBundleSignature
20 | ????
21 | CFBundleVersion
22 | 1
23 | LSRequiresIPhoneOS
24 |
25 | NSMainNibFile
26 | LaunchScreen
27 | UILaunchStoryboardName
28 | LaunchScreen
29 | UIRequiredDeviceCapabilities
30 |
31 | armv7
32 |
33 | UISupportedInterfaceOrientations
34 |
35 | UIInterfaceOrientationPortrait
36 | UIInterfaceOrientationLandscapeLeft
37 | UIInterfaceOrientationLandscapeRight
38 |
39 |
40 |
41 |
--------------------------------------------------------------------------------
/MONUniformFlowLayoutSample/default.json:
--------------------------------------------------------------------------------
1 | {
2 | "sections": [
3 | {
4 | "item_height": 100,
5 | "header_height": 40,
6 | "footer_height": 40,
7 | "portrait_number_of_columns": 3,
8 | "landscape_number_of_columns": 2,
9 | "number_of_items": 20,
10 | "item_color": "0x15ab12",
11 | "header_color": "0x984acc",
12 | "footer_color": "0xbcd112"
13 | },
14 | {
15 | "item_height": 75,
16 | "header_height": 40,
17 | "footer_height": 40,
18 | "portrait_number_of_columns": 4,
19 | "landscape_number_of_columns": 2,
20 | "number_of_items": 10,
21 | "item_color": "0xab123d",
22 | "header_color": "0x5fe1e1",
23 | "footer_color": "0xb58a24"
24 | },
25 | {
26 | "item_height": 75,
27 | "header_height": 40,
28 | "footer_height": 40,
29 | "portrait_number_of_columns": 3,
30 | "landscape_number_of_columns": 2,
31 | "number_of_items": 80,
32 | "item_color": "0x2d34c1",
33 | "header_color": "0xf122c2",
34 | "footer_color": "0x23443c"
35 | }
36 | ],
37 | "content_inset": {
38 | "top": 0,
39 | "left": 10,
40 | "bottom": 0,
41 | "right": 10
42 | },
43 | "item_spacing": {
44 | "horizontal": 10,
45 | "vertical": 20
46 | },
47 | "section_spacing": 0,
48 | "sticky_header": true
49 | }
--------------------------------------------------------------------------------
/MONUniformFlowLayoutSample/AppDelegate.m:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.m
3 | // CollectionSample
4 | //
5 | // Created by mownier on 12/2/14.
6 | // Copyright (c) 2014 mownier. All rights reserved.
7 | //
8 |
9 | #import "AppDelegate.h"
10 | #import "InputViewController.h"
11 |
12 | @interface AppDelegate ()
13 |
14 | @end
15 |
16 | @implementation AppDelegate
17 |
18 |
19 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
20 | // Override point for customization after application launch.
21 | self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
22 | InputViewController *vc = [InputViewController new];
23 | UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:vc];
24 | self.window.rootViewController = nav;
25 | [self.window makeKeyAndVisible];
26 | return YES;
27 | }
28 |
29 | - (void)applicationWillResignActive:(UIApplication *)application {
30 | // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
31 | // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
32 | }
33 |
34 | - (void)applicationDidEnterBackground:(UIApplication *)application {
35 | // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
36 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
37 | }
38 |
39 | - (void)applicationWillEnterForeground:(UIApplication *)application {
40 | // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
41 | }
42 |
43 | - (void)applicationDidBecomeActive:(UIApplication *)application {
44 | // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
45 | }
46 |
47 | - (void)applicationWillTerminate:(UIApplication *)application {
48 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
49 | }
50 |
51 | @end
52 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # MONUniformFlowLayout
2 | A simple flow layout the handles the arrangement of the items in a collection view uniformly based on the given number of columns, height of the item, inter item spacing, header height, and footer height for a particular section.
3 |
4 |
5 | 
6 |
7 | ## Installation
8 | * Manual Install
9 |
10 | ```
11 | 1. Add the files 'MONUniformFlowLayout.h' and 'MONUniformFlowLayout.m' to your project.
12 | 2. Then import the header file to use it.
13 | ```
14 |
15 | * Via CocoaPods
16 |
17 | ```
18 | 1. Add 'pod MONUniformFlowLayout' in your Podfile.
19 | 2. Then 'pod install' in the terminal.
20 | ```
21 |
22 | ## Setting as UICollectionView's Layout
23 | ```objective-c
24 | MONUniformFlowLayout *layout = [MONUniformFlowLayout new];
25 | layout.interItemSpacing = MONInterItemSpacingMake(10.0f, 10.0f);
26 | layout.enableStickyHeader = YES;
27 |
28 | UICollectionView *collectionView = [[UICollectionView alloc] initWithFrame:self.view.bounds
29 | collectionViewLayout:layout];
30 | ```
31 | The property `interItemSpacing` is the horizontal and the vertical space between items for all sections while the property `enableStickyHeader` gives an option to the user whether the collection view should enable or disable sticky header views for all sections.
32 |
33 | The static inline method `MONInterItemSpacingMake(CGFloat x, CGFloat y)` creates a struct defining the horizontal and vertical spaces between items.
34 |
35 | ## MONUniformFlowLayoutDelegate Methods
36 | ```objective-c
37 | @required
38 | // Gets the item height in a particular section
39 | - (CGFloat)collectionView:(UICollectionView *)collectionView
40 | layout:(MONUniformFlowLayout *)layout
41 | itemHeightInSection:(NSInteger)section;
42 |
43 | @optional
44 | // Gets the header height in a particular section
45 | - (CGFloat)collectionView:(UICollectionView *)collectionView
46 | layout:(MONUniformFlowLayout *)layout
47 | headerHeightInSection:(NSInteger)section;
48 |
49 | // Gets the footer height in a particular section
50 | - (CGFloat)collectionView:(UICollectionView *)collectionView
51 | layout:(MONUniformFlowLayout *)layout
52 | footerHeightInSection:(NSInteger)section;
53 |
54 | // Gets the spacing between sections
55 | - (CGFloat)collectionView:(UICollectionView *)collectionView
56 | sectionSpacingForlayout:(MONUniformFlowLayout *)layout;
57 |
58 | // Gets the number of columns in a particular section
59 | - (NSUInteger)collectionView:(UICollectionView *)collectionView
60 | layout:(MONUniformFlowLayout *)layout
61 | numberOfColumnsInSection:(NSInteger)section;)
62 | ```
63 |
64 | Usage in a UIViewController
65 |
66 | ```objective-c
67 | @interface ViewController : UIViewController
70 | ...
71 | @end
72 | ```
--------------------------------------------------------------------------------
/MONUniformFlowLayoutSample/InputViewController.m:
--------------------------------------------------------------------------------
1 | //
2 | // InputViewController.m
3 | // CollectionSample
4 | //
5 | // Created by mownier on 12/10/14.
6 | // Copyright (c) 2014 mownier. All rights reserved.
7 | //
8 |
9 | #import "InputViewController.h"
10 | #import "ViewController.h"
11 |
12 | @interface InputViewController ()
13 |
14 | @property (strong, nonatomic) UITextView *textView;
15 |
16 | - (void)tapRightBarButtonItem;
17 | - (void)tapLeftBarButtonItem;
18 |
19 | - (NSString *)getDefaultJSONString;
20 |
21 | @end
22 |
23 | @implementation InputViewController
24 |
25 | #pragma mark -
26 | #pragma mark - View Cycle
27 |
28 | - (void)viewDidLoad {
29 | [super viewDidLoad];
30 | self.view.backgroundColor = [UIColor lightGrayColor];
31 | [self.textView becomeFirstResponder];
32 | [self.view addSubview:self.textView];
33 | NSDictionary *views = @{ @"textView": self.textView };
34 | [self.view addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|[textView]|" options:0 metrics:0 views:views]];
35 | [self.view addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|[textView]|" options:0 metrics:0 views:views]];
36 |
37 | UIBarButtonItem *rightBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"Go" style:UIBarButtonItemStylePlain target:self action:@selector(tapRightBarButtonItem)];
38 | UIBarButtonItem *leftBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"Default" style:UIBarButtonItemStylePlain target:self action:@selector(tapLeftBarButtonItem)];
39 | self.navigationItem.rightBarButtonItem = rightBarButtonItem;
40 | self.navigationItem.leftBarButtonItem = leftBarButtonItem;
41 | }
42 |
43 | #pragma mark -
44 | #pragma mark - Actions
45 |
46 | - (void)tapRightBarButtonItem {
47 | NSError *error;
48 | NSDictionary *inputInfo = [NSJSONSerialization JSONObjectWithData:[self.textView.text dataUsingEncoding:NSUTF8StringEncoding] options:0 error:&error];
49 | if (error) {
50 | UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Malformed JSON format" message:error.localizedDescription delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
51 | [alertView show];
52 | return;
53 | }
54 | ViewController *vc = [ViewController new];
55 | vc.inputInfo = inputInfo;
56 | [self.navigationController pushViewController:vc animated:YES];
57 | }
58 |
59 | - (void)tapLeftBarButtonItem {
60 | self.textView.text = [self getDefaultJSONString];
61 | }
62 |
63 | #pragma mark -
64 | #pragma mark - Text View
65 |
66 | - (UITextView *)textView {
67 | if (!_textView) {
68 | _textView = [[UITextView alloc] initWithFrame:CGRectZero];
69 | _textView.backgroundColor = [UIColor clearColor];
70 | _textView.translatesAutoresizingMaskIntoConstraints = NO;
71 | _textView.contentInset = UIEdgeInsetsMake(0, 0, 260.0f, 0);
72 | _textView.scrollIndicatorInsets = UIEdgeInsetsMake(0, 0, 260.0f, 0);
73 | _textView.text = [self getDefaultJSONString];
74 | }
75 | return _textView;
76 | }
77 |
78 | #pragma mark -
79 | #pragma mark - Default JSON String
80 |
81 | - (NSString *)getDefaultJSONString {
82 | NSBundle *bundle = [NSBundle mainBundle];
83 | return [NSString stringWithContentsOfFile:[bundle pathForResource:@"default" ofType:@"json"] encoding:NSUTF8StringEncoding error:nil];
84 | }
85 |
86 | @end
87 |
--------------------------------------------------------------------------------
/MONUniformFlowLayout/MONUniformFlowLayout.h:
--------------------------------------------------------------------------------
1 | //
2 | // MONUniformFlowLayout.h
3 | //
4 | // Created by mownier on 12/2/14.
5 | // Copyright (c) 2014 mownier. All rights reserved.
6 | //
7 |
8 | #import
9 |
10 | /**
11 | * Spacing for the items
12 | */
13 | typedef struct MONInterItemSpacing {
14 | CGFloat x, y;
15 | } MONInterItemSpacing;
16 |
17 | /**
18 | * Creates an InterItemSpacing struct
19 | */
20 | static inline MONInterItemSpacing MONInterItemSpacingMake(CGFloat x, CGFloat y) {
21 | MONInterItemSpacing spacing = {x, y};
22 | return spacing;
23 | }
24 |
25 | @interface MONUniformFlowLayout : UICollectionViewFlowLayout
26 |
27 | /// The inter spacing for all items
28 | @property (readwrite, nonatomic) MONInterItemSpacing interItemSpacing;
29 |
30 | /// Condition to enable/disable sticky headers
31 | @property (readwrite, nonatomic) BOOL enableStickyHeader;
32 |
33 | /**
34 | * Computes the width of all the items for a particular section
35 | * @param section A particular section in the collection view
36 | * @return The width of all the items for a particular section
37 | */
38 | - (CGFloat)computeItemWidthInSection:(NSInteger)section;
39 |
40 | @end
41 |
42 | /**
43 | * Handles the definition of the item height, header height,
44 | * footer height, section spacing, and number of columns
45 | * for a particular section
46 | */
47 | @protocol MONUniformFlowLayoutDelegate
48 |
49 | /**
50 | * Gets the item height in a particular section
51 | * @param collectionView The involved UICollectionView
52 | * layout The involed UICollectionViewFlowLayout
53 | * section The section that needs the value of the height of it's items
54 | * @return Height for all the section's items
55 | */
56 | - (CGFloat)collectionView:(UICollectionView *)collectionView layout:(MONUniformFlowLayout *)layout itemHeightInSection:(NSInteger)section;
57 |
58 | @optional
59 |
60 | /**
61 | * Gets the header height in a particular section
62 | * @param collectionView The involved UICollectionView
63 | * layout The involed UICollectionViewFlowLayout
64 | * section The section that needs the value of the it's header height
65 | * @return Height of the section's header
66 | */
67 | - (CGFloat)collectionView:(UICollectionView *)collectionView layout:(MONUniformFlowLayout *)layout headerHeightInSection:(NSInteger)section;
68 |
69 | /**
70 | * Gets the footer height in a particular section
71 | * @param collectionView The involved UICollectionView
72 | * layout The involed UICollectionViewFlowLayout
73 | * section The section that needs the value of the it's footer height
74 | * @return Height of the section's footer
75 | */
76 | - (CGFloat)collectionView:(UICollectionView *)collectionView layout:(MONUniformFlowLayout *)layout footerHeightInSection:(NSInteger)section;
77 |
78 | /**
79 | * Gets the spacing between sections
80 | * @param collectionView The involved UICollectionView
81 | * layout The involed UICollectionViewFlowLayout
82 | * @return Section spacing between sections
83 | */
84 | - (CGFloat)collectionView:(UICollectionView *)collectionView sectionSpacingForlayout:(MONUniformFlowLayout *)layout;
85 |
86 | /**
87 | * Gets the number of columns in a particular section
88 | * @param collectionView The involved UICollectionView
89 | * layout The involed UICollectionViewFlowLayout
90 | * section The section that needs the value of the it's footer height
91 | * @return Number of columns
92 | */
93 | - (NSUInteger)collectionView:(UICollectionView *)collectionView layout:(MONUniformFlowLayout *)layout numberOfColumnsInSection:(NSInteger)section;
94 |
95 | @end
96 |
97 |
98 |
99 |
--------------------------------------------------------------------------------
/MONUniformFlowLayoutSample/Base.lproj/LaunchScreen.xib:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
20 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
--------------------------------------------------------------------------------
/MONUniformFlowLayoutSample/ViewController.m:
--------------------------------------------------------------------------------
1 | //
2 | // ViewController.m
3 | // CollectionSample
4 | //
5 | // Created by mownier on 12/2/14.
6 | // Copyright (c) 2014 mownier. All rights reserved.
7 | //
8 |
9 | #import "ViewController.h"
10 | #import "CollectionViewCell.h"
11 | #import "MONUniformFlowLayout.h"
12 | #import "CollectionHeaderView.h"
13 | #import "CollectionFooterView.h"
14 |
15 | static NSString *kCollectionViewCellIdentifier = @"kCollectionViewCellIdentifier";
16 | static NSString *kCollectionViewSectionHeaderIdentifier = @"kCollectionViewSectionHeaderIdentifier";
17 | static NSString *kCollectionViewSectionFooterIdentifier = @"kCollectionViewSectionFooterIdentifier";
18 |
19 | @interface ViewController ()
20 |
21 | @property (strong, nonatomic) UICollectionView *collectionView;
22 | @property (strong, nonatomic) MONUniformFlowLayout *simpleLayout;
23 |
24 | - (void)addVerticalConstraints:(NSArray **)verticalConstraints
25 | horizontalConstraints:(NSArray **)horizontalConstraints
26 | views:(NSDictionary *)views
27 | metrics:(NSDictionary *)metrics;
28 |
29 | - (UIColor *)colorWithHexString:(NSString *)stringToConvert;
30 |
31 | @end
32 |
33 | @implementation ViewController
34 |
35 | #pragma mark -
36 | #pragma mark - View Lifecycle
37 |
38 | - (void)viewDidLoad {
39 | [super viewDidLoad];
40 | self.view.backgroundColor = [UIColor lightGrayColor];
41 |
42 | [self.collectionView registerClass:[CollectionViewCell class] forCellWithReuseIdentifier:kCollectionViewCellIdentifier];
43 | [self.collectionView registerClass:[CollectionHeaderView class] forSupplementaryViewOfKind:UICollectionElementKindSectionHeader withReuseIdentifier:kCollectionViewSectionHeaderIdentifier];
44 | [self.collectionView registerClass:[CollectionFooterView class] forSupplementaryViewOfKind:UICollectionElementKindSectionFooter withReuseIdentifier:kCollectionViewSectionFooterIdentifier];
45 | [self.view addSubview:self.collectionView];
46 |
47 | NSArray *v;
48 | NSArray *h;
49 | NSDictionary *views = @{ @"collectionView": self.collectionView };
50 | [self addVerticalConstraints:&v horizontalConstraints:&h views:views metrics:nil];
51 | [self.view addConstraints:v];
52 | [self.view addConstraints:h];
53 | }
54 |
55 | #pragma mark -
56 | #pragma mark - Add Vertical and Horizontal Constraints
57 |
58 | - (void)addVerticalConstraints:(NSArray *__autoreleasing *)verticalConstraints
59 | horizontalConstraints:(NSArray *__autoreleasing *)horizontalConstraints
60 | views:(NSDictionary *)views
61 | metrics:(NSDictionary *)metrics {
62 | NSMutableArray *v = [NSMutableArray new];
63 | NSMutableArray *h = [NSMutableArray new];
64 |
65 | [v addObjectsFromArray:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|-0-[collectionView]-0-|" options:0 metrics:metrics views:views]];
66 |
67 | [h addObjectsFromArray:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|-0-[collectionView]-0-|" options:0 metrics:metrics views:views]];
68 |
69 | *verticalConstraints = v;
70 | *horizontalConstraints = h;
71 | }
72 |
73 | #pragma mark -
74 | #pragma mark - Collection View
75 |
76 | - (UICollectionView *)collectionView {
77 | if (!_collectionView) {
78 | _collectionView = [[UICollectionView alloc] initWithFrame:CGRectZero collectionViewLayout:self.simpleLayout];
79 | _collectionView.translatesAutoresizingMaskIntoConstraints = NO;
80 | _collectionView.delegate = self;
81 | _collectionView.dataSource = self;
82 | _collectionView.backgroundColor = [UIColor clearColor];
83 | NSDictionary *contentInset = [self.inputInfo objectForKey:@"content_inset"];
84 | _collectionView.contentInset = UIEdgeInsetsMake([[contentInset objectForKey:@"top"] floatValue],
85 | [[contentInset objectForKey:@"left"] floatValue],
86 | [[contentInset objectForKey:@"bottom"] floatValue],
87 | [[contentInset objectForKey:@"right"] floatValue]);
88 | }
89 | return _collectionView;
90 | }
91 |
92 | - (MONUniformFlowLayout *)simpleLayout {
93 | if (!_simpleLayout) {
94 | _simpleLayout = [[MONUniformFlowLayout alloc] init];
95 | NSDictionary *itemSpacingInfo = [self.inputInfo objectForKey:@"item_spacing"];
96 | _simpleLayout.interItemSpacing = MONInterItemSpacingMake([[itemSpacingInfo objectForKey:@"horizontal"] floatValue],
97 | [[itemSpacingInfo objectForKey:@"vertical"] floatValue]);
98 | _simpleLayout.enableStickyHeader = [[self.inputInfo objectForKey:@"sticky_header"] boolValue];
99 | }
100 | return _simpleLayout;
101 | }
102 |
103 | #pragma mark -
104 | #pragma mark - Collection View Delegate
105 |
106 | - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView
107 | cellForItemAtIndexPath:(NSIndexPath *)indexPath {
108 | CollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:kCollectionViewCellIdentifier forIndexPath:indexPath];
109 | NSArray *sections = [self.inputInfo objectForKey:@"sections"];
110 | NSDictionary *sectionDetails = [sections objectAtIndex:indexPath.section];
111 | cell.backgroundColor = [self colorWithHexString:[sectionDetails objectForKey:@"item_color"]];
112 | return cell;
113 | }
114 |
115 | - (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath {
116 | UIViewController *vc = [UIViewController new];
117 | vc.view.backgroundColor = [UIColor lightGrayColor];
118 | [self.navigationController pushViewController:vc animated:YES];
119 | }
120 |
121 | - (UICollectionReusableView *)collectionView:(UICollectionView *)collectionView
122 | viewForSupplementaryElementOfKind:(NSString *)kind
123 | atIndexPath:(NSIndexPath *)indexPath {
124 | UICollectionReusableView *reusableView = nil;
125 | NSArray *sections = [self.inputInfo objectForKey:@"sections"];
126 | NSDictionary *sectionDetails = [sections objectAtIndex:indexPath.section];
127 |
128 | if ([kind isEqualToString:UICollectionElementKindSectionHeader]) {
129 | CollectionHeaderView *headerView = [collectionView dequeueReusableSupplementaryViewOfKind:kind withReuseIdentifier:kCollectionViewSectionHeaderIdentifier forIndexPath:indexPath];
130 | headerView.backgroundColor = [self colorWithHexString:[sectionDetails objectForKey:@"header_color"]];
131 | reusableView = headerView;
132 | } else if ([kind isEqualToString:UICollectionElementKindSectionFooter]) {
133 | CollectionFooterView *footerView = [collectionView dequeueReusableSupplementaryViewOfKind:kind withReuseIdentifier:kCollectionViewSectionFooterIdentifier forIndexPath:indexPath];
134 | footerView.backgroundColor = [self colorWithHexString:[sectionDetails objectForKey:@"footer_color"]];
135 | reusableView = footerView;
136 | }
137 |
138 | return reusableView;
139 | }
140 |
141 | #pragma mark -
142 | #pragma mark - Collection View Data Source
143 |
144 | - (NSInteger)collectionView:(UICollectionView *)collectionView
145 | numberOfItemsInSection:(NSInteger)section {
146 | NSArray *sections = [self.inputInfo objectForKey:@"sections"];
147 | NSDictionary *sectionDetails = [sections objectAtIndex:section];
148 | return [[sectionDetails objectForKey:@"number_of_items"] integerValue];
149 | }
150 |
151 | - (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView {
152 | return [[self.inputInfo objectForKey:@"sections"] count];
153 | }
154 |
155 | #pragma mark -
156 | #pragma mark - Get Number of Columns
157 |
158 | - (NSUInteger)getNumberOfColumnsInSection:(NSInteger)section {
159 | UIDevice *device = [UIDevice currentDevice];
160 | NSArray *sections = [self.inputInfo objectForKey:@"sections"];
161 | NSDictionary *sectionDetails = [sections objectAtIndex:section];
162 | if (UIDeviceOrientationIsLandscape(device.orientation)) {
163 | return [[sectionDetails objectForKey:@"landscape_number_of_columns"] floatValue];
164 | } else {
165 | return [[sectionDetails objectForKey:@"portrait_number_of_columns"] floatValue];
166 | }
167 | }
168 |
169 | #pragma mark -
170 | #pragma mark - Simple Flow Layout Delegate
171 |
172 | - (CGFloat)collectionView:(UICollectionView *)collectionView
173 | layout:(MONUniformFlowLayout *)layout
174 | itemHeightInSection:(NSInteger)section {
175 | NSArray *sections = [self.inputInfo objectForKey:@"sections"];
176 | NSDictionary *sectionDetails = [sections objectAtIndex:section];
177 | return [[sectionDetails objectForKey:@"item_height"] floatValue];
178 | }
179 |
180 | - (CGFloat)collectionView:(UICollectionView *)collectionView
181 | layout:(MONUniformFlowLayout *)layout
182 | headerHeightInSection:(NSInteger)section {
183 | NSArray *sections = [self.inputInfo objectForKey:@"sections"];
184 | NSDictionary *sectionDetails = [sections objectAtIndex:section];
185 | return [[sectionDetails objectForKey:@"header_height"] floatValue];
186 | }
187 |
188 | - (CGFloat)collectionView:(UICollectionView *)collectionView
189 | layout:(MONUniformFlowLayout *)layout
190 | footerHeightInSection:(NSInteger)section {
191 | NSArray *sections = [self.inputInfo objectForKey:@"sections"];
192 | NSDictionary *sectionDetails = [sections objectAtIndex:section];
193 | return [[sectionDetails objectForKey:@"footer_height"] floatValue];
194 | }
195 |
196 | - (CGFloat)collectionView:(UICollectionView *)collectionView
197 | sectionSpacingForlayout:(MONUniformFlowLayout *)layout {
198 | return [[self.inputInfo objectForKey:@"section_spacing"] floatValue];
199 | }
200 |
201 | - (NSUInteger)collectionView:(UICollectionView *)collectionView
202 | layout:(MONUniformFlowLayout *)layout
203 | numberOfColumnsInSection:(NSInteger)section {
204 | return [self getNumberOfColumnsInSection:section];
205 | }
206 |
207 | #pragma mark -
208 | #pragma mark - Convert Hext String to Color
209 |
210 | - (UIColor *)colorWithHexString:(NSString *)stringToConvert {
211 | NSString *noHashString = [stringToConvert stringByReplacingOccurrencesOfString:@"#" withString:@""]; // remove the #
212 | NSScanner *scanner = [NSScanner scannerWithString:noHashString];
213 | [scanner setCharactersToBeSkipped:[NSCharacterSet symbolCharacterSet]]; // remove + and $
214 |
215 | unsigned hex;
216 | if (![scanner scanHexInt:&hex]) return nil;
217 | int r = (hex >> 16) & 0xFF;
218 | int g = (hex >> 8) & 0xFF;
219 | int b = (hex) & 0xFF;
220 |
221 | return [UIColor colorWithRed:r / 255.0f green:g / 255.0f blue:b / 255.0f alpha:1.0f];
222 | }
223 |
224 | @end
225 |
--------------------------------------------------------------------------------
/MONUniformFlowLayout/MONUniformFlowLayout.m:
--------------------------------------------------------------------------------
1 | //
2 | // MONUniformFlowLayout.m
3 | //
4 | // Created by mownier on 12/2/14.
5 | // Copyright (c) 2014 mownier. All rights reserved.
6 | //
7 |
8 | #import "MONUniformFlowLayout.h"
9 |
10 | @interface MONUniformFlowLayout ()
11 |
12 | /// Used to get the content height of the collection view
13 | @property (readonly, nonatomic) CGFloat collectionViewContentHeight;
14 |
15 | /// Used to get the width of the section's header
16 | @property (readonly, nonatomic) CGFloat headerWidth;
17 |
18 | /// Used to get the width of the section's footer
19 | @property (readonly, nonatomic) CGFloat footerWidth;
20 |
21 | /// Used to get the number of sections
22 | @property (readonly, nonatomic) NSInteger numberOfSections;
23 |
24 | /// Used to get the spacing between sections
25 | @property (readonly, nonatomic) CGFloat sectionSpacing;
26 |
27 | /**
28 | * Computes the height of an item in a section
29 | * @param section The section that needs the height for it's item
30 | * @return The height for all items in a section
31 | */
32 | - (CGFloat)computeItemHeightInSection:(NSInteger)section;
33 |
34 | /**
35 | * Computes the total spacing (origin-y) between items in a section
36 | * @param section The section that needs the total spacing between items
37 | * @return The total spacing between items in a section
38 | */
39 | - (CGFloat)computeTotalInterItemSpacingYInSection:(NSInteger)section;
40 |
41 | /**
42 | * Computes the total height for all the items in a section
43 | * @param section The section that needs the total height for all items
44 | * @return The total height for all items in a section
45 | */
46 | - (CGFloat)computeTotalItemHeightInSection:(NSInteger)section;
47 |
48 | /**
49 | * Computes the origin-y of an item in a section
50 | * @param section The section that needs the origin-y of an item
51 | * @return The origin-y of an item in a section
52 | */
53 | - (CGFloat)computePositionYInSection:(NSInteger)section;
54 |
55 | /**
56 | * Computes the origin-y of the header in a section
57 | * @param section The section that needs the origin-y of the header
58 | * @return The origin-y of the header in a section
59 | */
60 | - (CGFloat)computeHeaderPositionYInSection:(NSInteger)section;
61 |
62 | /**
63 | * Computes the origin-y of the footer in a section
64 | * @param section The section that needs the origin-y of the footer
65 | * @return The origin-y of the footer in a section
66 | */
67 | - (CGFloat)computeFooterPositionYInSection:(NSInteger)section;
68 |
69 | /**
70 | * Gets the number of rows in a section
71 | * @param section The section that needs it's number of rows
72 | * @return Number of rows in a section
73 | */
74 | - (NSInteger)getNumberOfRowsInSection:(NSInteger)section;
75 |
76 | /**
77 | * Gets the number of items in a section
78 | * @param section The section that needs it's number of items
79 | * @return Number of items in a section
80 | */
81 | - (NSInteger)getNumberOfItemsInSection:(NSInteger)section;
82 |
83 | /**
84 | * Gets the number of columns in a section
85 | * @param section The section that needs it's number of columns
86 | # @return Number of columns in a section
87 | */
88 | - (NSInteger)getNumberOfColumnsInSection:(NSInteger)section;
89 |
90 | /**
91 | * Gets the height of the section's header
92 | * @param section The section that needs the header height
93 | * @return Height of the header in a section
94 | */
95 | - (CGFloat)getHeaderHeightInSection:(NSInteger)section;
96 |
97 | /**
98 | * Gets the height of the section's footer
99 | * @param section The section that needs the footer height
100 | * @return Height of the footer in a section
101 | */
102 | - (CGFloat)getFooterHeightInSection:(NSInteger)section;
103 |
104 | /**
105 | * Modifies the attributes of an item relative to the collection view
106 | * @param indexPath The targeted indexPath of the item's attributes to modify
107 | */
108 | - (void)modifyItemAttributes:(UICollectionViewLayoutAttributes *)attributes indexPath:(NSIndexPath *)indexPath;
109 |
110 | /**
111 | * Modifies the attributes of a section's header relative to the collection view
112 | * @param section The section of the header's attributes to modify
113 | */
114 | - (void)modifyHeaderAttributes:(UICollectionViewLayoutAttributes *)attributes section:(NSInteger)section;
115 |
116 | /**
117 | * Modifies the attributes of a section's footer relative to the collection view
118 | * @param section The section of the footer's attributes to modify
119 | */
120 | - (void)modifyFooterAttributes:(UICollectionViewLayoutAttributes *)attributes section:(NSInteger)section;
121 |
122 | @end
123 |
124 | @implementation MONUniformFlowLayout
125 |
126 | #pragma mark -
127 | #pragma mark - Layout
128 |
129 | - (void)prepareLayout {
130 | [super prepareLayout];
131 | }
132 |
133 | #pragma mark -
134 | #pragma mark - Attributes Modification
135 |
136 | - (void)modifyItemAttributes:(UICollectionViewLayoutAttributes *)attributes indexPath:(NSIndexPath *)indexPath {
137 | NSUInteger numberOfColumnsInSection = [self getNumberOfColumnsInSection:indexPath.section];
138 | assert(numberOfColumnsInSection > 0);
139 | NSInteger currentSection = indexPath.section;
140 | NSInteger currentRow = indexPath.row / numberOfColumnsInSection;
141 | NSInteger currentColumn = indexPath.row % numberOfColumnsInSection;
142 |
143 | CGRect frame = attributes.frame;
144 |
145 | frame.origin.x = (self.interItemSpacing.x * currentColumn) + ([self computeItemWidthInSection:currentSection] * currentColumn);
146 | frame.origin.y = [self computePositionYInSection:currentSection] + (self.interItemSpacing.y * currentRow) + ([self computeItemHeightInSection:currentSection] * currentRow);
147 | frame.size.width = [self computeItemWidthInSection:currentSection];
148 | frame.size.height = [self computeItemHeightInSection:currentSection];
149 |
150 | attributes.frame = frame;
151 | }
152 |
153 | - (void)modifyHeaderAttributes:(UICollectionViewLayoutAttributes *)attributes section:(NSInteger)section {
154 | CGRect frame = attributes.frame;
155 | frame.origin.x = -self.collectionView.contentInset.left;
156 | frame.origin.y = [self computeHeaderPositionYInSection:section];
157 | frame.size.width = self.headerWidth;
158 | frame.size.height = [self getHeaderHeightInSection:section];
159 | attributes.frame = frame;
160 | attributes.zIndex = 1024;
161 | }
162 |
163 | - (void)modifyFooterAttributes:(UICollectionViewLayoutAttributes *)attributes section:(NSInteger)section {
164 | CGRect frame = attributes.frame;
165 | frame.origin.x = -self.collectionView.contentInset.left;
166 | frame.origin.y = [self computeFooterPositionYInSection:section];
167 | frame.size.width = self.footerWidth;
168 | frame.size.height = [self getFooterHeightInSection:section];
169 | attributes.frame = frame;
170 | attributes.zIndex = 1024;
171 | }
172 |
173 | - (UICollectionViewLayoutAttributes *)layoutAttributesForSupplementaryViewOfKind:(NSString *)elementKind
174 | atIndexPath:(NSIndexPath *)indexPath {
175 | if ([elementKind isEqualToString:UICollectionElementKindSectionHeader]) {
176 | UICollectionViewLayoutAttributes *attributes = [UICollectionViewLayoutAttributes layoutAttributesForSupplementaryViewOfKind:UICollectionElementKindSectionHeader withIndexPath:indexPath];
177 | [self modifyHeaderAttributes:attributes section:indexPath.section];
178 | return attributes;
179 | } else if ([elementKind isEqualToString:UICollectionElementKindSectionFooter]) {
180 | UICollectionViewLayoutAttributes *attributes = [UICollectionViewLayoutAttributes layoutAttributesForSupplementaryViewOfKind:UICollectionElementKindSectionFooter withIndexPath:indexPath];
181 |
182 | [self modifyFooterAttributes:attributes section:indexPath.section];
183 | return attributes;
184 | }
185 | return nil;
186 | }
187 |
188 | - (UICollectionViewLayoutAttributes *)layoutAttributesForItemAtIndexPath:(NSIndexPath *)indexPath {
189 | UICollectionViewLayoutAttributes *attributes = [UICollectionViewLayoutAttributes layoutAttributesForCellWithIndexPath:indexPath];
190 | [self modifyItemAttributes:attributes indexPath:indexPath];
191 | return attributes;
192 | }
193 |
194 | - (NSArray *)layoutAttributesForElementsInRect:(CGRect)rect {
195 | NSMutableArray *allAttributesInRect = [NSMutableArray new];
196 |
197 | NSUInteger numberOfSections = self.numberOfSections;
198 | for (int section = 0; section < numberOfSections; section++) {
199 | NSIndexPath *indexPath = [NSIndexPath indexPathForItem:0 inSection:section];
200 |
201 | UICollectionViewLayoutAttributes *headerAttributes = [self layoutAttributesForSupplementaryViewOfKind:UICollectionElementKindSectionHeader atIndexPath:indexPath];
202 | if (headerAttributes && CGRectIntersectsRect(headerAttributes.frame, rect)) {
203 | [allAttributesInRect addObject:headerAttributes];
204 | }
205 |
206 | UICollectionViewLayoutAttributes *footerAttributes = [self layoutAttributesForSupplementaryViewOfKind:UICollectionElementKindSectionFooter atIndexPath:indexPath];
207 | if (footerAttributes && CGRectIntersectsRect(footerAttributes.frame, rect)) {
208 | [allAttributesInRect addObject:footerAttributes];
209 | }
210 |
211 | NSUInteger numberOfItems = [self getNumberOfItemsInSection:section];
212 | for (int item = 0; item < numberOfItems; item++) {
213 | NSIndexPath *indexPath = [NSIndexPath indexPathForRow:item inSection:section];
214 | UICollectionViewLayoutAttributes *attributes = [self layoutAttributesForItemAtIndexPath:indexPath];
215 | if (CGRectIntersectsRect(attributes.frame, rect)) {
216 | [allAttributesInRect addObject:attributes];
217 | }
218 | }
219 | }
220 |
221 | return allAttributesInRect;
222 | }
223 |
224 | #pragma mark -
225 | #pragma mark - Content Size
226 |
227 | - (CGSize)collectionViewContentSize {
228 | CGSize contentSize = [super collectionViewContentSize];
229 | contentSize.height = self.collectionViewContentHeight;
230 | return contentSize;
231 | }
232 |
233 | - (CGFloat)collectionViewContentHeight {
234 | NSInteger lastSection = self.numberOfSections - 1;
235 | CGFloat height = [self computePositionYInSection:lastSection] + [self getFooterHeightInSection:lastSection] + [self computeTotalInterItemSpacingYInSection:lastSection] + [self computeTotalItemHeightInSection:lastSection];
236 | return height;
237 | }
238 |
239 | #pragma mark -
240 | #pragma mark - Header and Footer
241 |
242 | - (CGFloat)headerWidth {
243 | return self.collectionView.frame.size.width;
244 | }
245 |
246 | - (CGFloat)footerWidth {
247 | return self.collectionView.frame.size.width;
248 | }
249 |
250 | - (CGFloat)getHeaderHeightInSection:(NSInteger)section {
251 | if (section < 0) {
252 | return 0;
253 | }
254 | id delegate = (id)self.collectionView.delegate;
255 | CGFloat headerHeight = 0;
256 | if (delegate && [delegate respondsToSelector:@selector(collectionView:layout:headerHeightInSection:)]) {
257 | headerHeight = [delegate collectionView:self.collectionView layout:self headerHeightInSection:section];
258 | }
259 | return headerHeight;
260 | }
261 |
262 | - (CGFloat)getFooterHeightInSection:(NSInteger)section {
263 | if (section < 0) {
264 | return 0;
265 | }
266 | id delegate = (id)self.collectionView.delegate;
267 | CGFloat footerHeight = 0;
268 | if (delegate && [delegate respondsToSelector:@selector(collectionView:layout:footerHeightInSection:)]) {
269 | footerHeight = [delegate collectionView:self.collectionView layout:self footerHeightInSection:section];
270 | }
271 | return footerHeight;
272 | }
273 |
274 | - (CGFloat)computeFooterPositionYInSection:(NSInteger)section {
275 | if (section < 0) {
276 | return 0;
277 | }
278 | // y-position of last row in section + itemHeightInSection + footerHeightInSection
279 | NSInteger lastRow = [self getNumberOfRowsInSection:section] - 1;
280 | CGFloat posiitonY = ([self computePositionYInSection:section] + (self.interItemSpacing.y * lastRow) + ([self computeItemHeightInSection:section] * lastRow)) + [self computeItemHeightInSection:section];
281 | return posiitonY;
282 | }
283 |
284 | - (CGFloat)computeHeaderPositionYInSection:(NSInteger)section {
285 | if (section < 0) {
286 | return 0;
287 | }
288 | // y-position of the first row in section - headerHeightInSection
289 | CGFloat positionY = [self computePositionYInSection:section] - [self getHeaderHeightInSection:section];
290 | if (self.enableStickyHeader) {
291 | CGFloat offsetY = self.collectionView.contentOffset.y;
292 | CGFloat offsetYToStick = positionY - self.collectionView.contentInset.top;
293 | CGFloat offsetYToGetOff = [self computeFooterPositionYInSection:section] - [self getHeaderHeightInSection:section] - self.collectionView.contentInset.top;
294 | if (offsetY >= offsetYToStick && offsetY < offsetYToGetOff) {
295 | return self.collectionView.contentInset.top + self.collectionView.contentOffset.y;
296 | } else if (offsetY >= offsetYToGetOff) {
297 | return self.collectionView.contentInset.top + self.collectionView.contentOffset.y - (offsetY - offsetYToGetOff); // (scrollUp1: -1, scrollUp2: -2, scrollUp3: -3)
298 | }
299 | }
300 | return positionY;
301 | }
302 |
303 | #pragma mark -
304 | #pragma mark - Item Size in Section
305 |
306 | - (CGFloat)computeItemWidthInSection:(NSInteger)section {
307 | if (section < 0) {
308 | return 0.0f;
309 | }
310 | NSUInteger numberOfColumnsInSection = [self getNumberOfColumnsInSection:section];
311 | CGFloat deductions = self.collectionView.contentInset.left + self.collectionView.contentInset.right + (self.interItemSpacing.x * (numberOfColumnsInSection - 1));
312 | CGFloat width = (self.collectionView.frame.size.width - deductions) / numberOfColumnsInSection;
313 | return width;
314 | }
315 |
316 | - (CGFloat)computeItemHeightInSection:(NSInteger)section {
317 | if (section < 0) {
318 | return 0.0f;
319 | }
320 | id delegate = (id)self.collectionView.delegate;
321 | CGFloat height = 0;
322 | if (delegate && [delegate respondsToSelector:@selector(collectionView:layout:itemHeightInSection:)]) {
323 | height = [delegate collectionView:self.collectionView layout:self itemHeightInSection:section];
324 | }
325 | return height;
326 | }
327 |
328 | #pragma mark -
329 | #pragma mark - Number of Items
330 |
331 | - (NSInteger)getNumberOfItemsInSection:(NSInteger)section {
332 | if (section < 0) {
333 | return 0;
334 | }
335 | NSInteger numberOfItems = [self.collectionView.dataSource collectionView:self.collectionView numberOfItemsInSection:section];
336 | return numberOfItems;
337 | }
338 |
339 | #pragma mark -
340 | #pragma mark - Sections
341 |
342 | - (NSInteger)numberOfSections {
343 | NSInteger numberOfSections = 1;
344 | if (self.collectionView && self.collectionView.dataSource && [self.collectionView.dataSource respondsToSelector:@selector(numberOfSectionsInCollectionView:)]) {
345 | numberOfSections = [self.collectionView.dataSource numberOfSectionsInCollectionView:self.collectionView];
346 | }
347 | return numberOfSections;
348 | }
349 |
350 | - (CGFloat)sectionSpacing {
351 | id delegate = (id)self.collectionView.delegate;
352 | CGFloat sectionSpacing = 0;
353 | if (delegate && [delegate respondsToSelector:@selector(collectionView:sectionSpacingForlayout:)]) {
354 | sectionSpacing = [delegate collectionView:self.collectionView sectionSpacingForlayout:self];
355 | }
356 | return sectionSpacing;
357 | }
358 |
359 | #pragma mark -
360 | #pragma mark - Rows
361 |
362 | - (NSInteger)getNumberOfRowsInSection:(NSInteger)section {
363 | if (section < 0) {
364 | return 0;
365 | }
366 | NSInteger numberOfItems = [self getNumberOfItemsInSection:section];
367 | NSInteger numberOfRows = ceil(numberOfItems / ([self getNumberOfColumnsInSection:section] * 1.0f));
368 | return numberOfRows;
369 | }
370 |
371 | #pragma mark -
372 | #pragma mark - Columns
373 |
374 | - (NSInteger)getNumberOfColumnsInSection:(NSInteger)section {
375 | if (section < 0) {
376 | return 0;
377 | }
378 | id delegate = (id)self.collectionView.delegate;
379 | NSInteger numberOfColumns = 1;
380 | if (delegate && [delegate respondsToSelector:@selector(collectionView:layout:numberOfColumnsInSection:)]) {
381 | numberOfColumns = [delegate collectionView:self.collectionView layout:self numberOfColumnsInSection:section];
382 | }
383 | return numberOfColumns;
384 | }
385 |
386 | #pragma mark -
387 | #pragma mark - Inter Item Spacing
388 |
389 | - (CGFloat)computeTotalInterItemSpacingYInSection:(NSInteger)section {
390 | if (section < 0) {
391 | return 0;
392 | }
393 | NSInteger numberOfRowsInSection = [self getNumberOfRowsInSection:section];
394 | CGFloat totalInterItemSpacingYInSection = (self.interItemSpacing.y * (numberOfRowsInSection - 1));
395 | return totalInterItemSpacingYInSection;
396 | }
397 |
398 | #pragma mark -
399 | #pragma mark - Total Height In Section
400 |
401 | - (CGFloat)computeTotalItemHeightInSection:(NSInteger)section {
402 | if (section < 0) {
403 | return 0;
404 | }
405 | NSInteger numberOfRowsInSection = [self getNumberOfRowsInSection:section];
406 | CGFloat itemHeight = [self computeItemHeightInSection:section];
407 | CGFloat totalHeightInSection = itemHeight * numberOfRowsInSection;
408 | return totalHeightInSection;
409 | }
410 |
411 | #pragma mark -
412 | #pragma mark - Overidden Setters and Getterss
413 |
414 | - (void)setInterItemSpacing:(MONInterItemSpacing)interItemSpacing {
415 | _interItemSpacing = interItemSpacing;
416 | [self invalidateLayout];
417 | }
418 |
419 | #pragma mark -
420 | #pragma mark - Position Y Computation
421 |
422 | - (CGFloat)computePositionYInSection:(NSInteger)section {
423 | CGFloat totalInterSectionSpacing = self.sectionSpacing * section;
424 | CGFloat totalInterItemSpacingY = 0;
425 | CGFloat totalSectionItemHeight = 0;
426 | CGFloat totalHeaderHeight = [self getHeaderHeightInSection:section];
427 | CGFloat totalFooterHeight = 0;
428 |
429 | for (NSInteger i = 0; i < section; i++) {
430 | totalInterItemSpacingY += [self computeTotalInterItemSpacingYInSection:i];
431 | totalSectionItemHeight += [self computeTotalItemHeightInSection:i];
432 | totalHeaderHeight += [self getHeaderHeightInSection:i];
433 | totalFooterHeight += [self getFooterHeightInSection:i];
434 | }
435 |
436 | CGFloat positionY = totalSectionItemHeight + totalInterSectionSpacing + totalInterItemSpacingY + totalHeaderHeight + totalFooterHeight;
437 | return positionY;
438 | }
439 |
440 | #pragma mark -
441 | #pragma mark - Invalidate Layout
442 |
443 | - (BOOL)shouldInvalidateLayoutForBoundsChange:(CGRect)newBounds {
444 | return YES;
445 | }
446 |
447 | @end
448 |
--------------------------------------------------------------------------------
/MONUniformFlowLayoutSample.xcodeproj/project.pbxproj:
--------------------------------------------------------------------------------
1 | // !$*UTF8*$!
2 | {
3 | archiveVersion = 1;
4 | classes = {
5 | };
6 | objectVersion = 46;
7 | objects = {
8 |
9 | /* Begin PBXBuildFile section */
10 | DF03B8F81A3828E1007E23DB /* MONUniformFlowLayout.m in Sources */ = {isa = PBXBuildFile; fileRef = DF03B8F71A3828E1007E23DB /* MONUniformFlowLayout.m */; };
11 | DF03B90C1A382B4B007E23DB /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = DF03B8FF1A382B4B007E23DB /* AppDelegate.m */; };
12 | DF03B90D1A382B4B007E23DB /* CollectionFooterView.m in Sources */ = {isa = PBXBuildFile; fileRef = DF03B9011A382B4B007E23DB /* CollectionFooterView.m */; };
13 | DF03B90E1A382B4B007E23DB /* CollectionHeaderView.m in Sources */ = {isa = PBXBuildFile; fileRef = DF03B9031A382B4B007E23DB /* CollectionHeaderView.m */; };
14 | DF03B90F1A382B4B007E23DB /* CollectionViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = DF03B9051A382B4B007E23DB /* CollectionViewCell.m */; };
15 | DF03B9101A382B4B007E23DB /* default.json in Resources */ = {isa = PBXBuildFile; fileRef = DF03B9061A382B4B007E23DB /* default.json */; };
16 | DF03B9111A382B4B007E23DB /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = DF03B9071A382B4B007E23DB /* Images.xcassets */; };
17 | DF03B9121A382B4B007E23DB /* InputViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = DF03B9091A382B4B007E23DB /* InputViewController.m */; };
18 | DF03B9131A382B4B007E23DB /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = DF03B90B1A382B4B007E23DB /* ViewController.m */; };
19 | DF03B91A1A382B94007E23DB /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = DF03B9181A382B94007E23DB /* main.m */; };
20 | DF03B91C1A382D49007E23DB /* Dummy.m in Sources */ = {isa = PBXBuildFile; fileRef = DF03B91B1A382D49007E23DB /* Dummy.m */; };
21 | DF03B91D1A382EA8007E23DB /* LaunchScreen.xib in Resources */ = {isa = PBXBuildFile; fileRef = DF03B9141A382B5E007E23DB /* LaunchScreen.xib */; };
22 | /* End PBXBuildFile section */
23 |
24 | /* Begin PBXContainerItemProxy section */
25 | DF7F16CC1A2D86CD00EF7DB4 /* PBXContainerItemProxy */ = {
26 | isa = PBXContainerItemProxy;
27 | containerPortal = DF7F16AA1A2D86CD00EF7DB4 /* Project object */;
28 | proxyType = 1;
29 | remoteGlobalIDString = DF7F16B11A2D86CD00EF7DB4;
30 | remoteInfo = CollectionSample;
31 | };
32 | /* End PBXContainerItemProxy section */
33 |
34 | /* Begin PBXFileReference section */
35 | DF03B8F61A3828E1007E23DB /* MONUniformFlowLayout.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MONUniformFlowLayout.h; sourceTree = ""; };
36 | DF03B8F71A3828E1007E23DB /* MONUniformFlowLayout.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MONUniformFlowLayout.m; sourceTree = ""; };
37 | DF03B8FA1A382B19007E23DB /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; };
38 | DF03B8FE1A382B4B007E23DB /* AppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = AppDelegate.h; path = MONUniformFlowLayoutSample/AppDelegate.h; sourceTree = SOURCE_ROOT; };
39 | DF03B8FF1A382B4B007E23DB /* AppDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = AppDelegate.m; path = MONUniformFlowLayoutSample/AppDelegate.m; sourceTree = SOURCE_ROOT; };
40 | DF03B9001A382B4B007E23DB /* CollectionFooterView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CollectionFooterView.h; path = MONUniformFlowLayoutSample/CollectionFooterView.h; sourceTree = SOURCE_ROOT; };
41 | DF03B9011A382B4B007E23DB /* CollectionFooterView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = CollectionFooterView.m; path = MONUniformFlowLayoutSample/CollectionFooterView.m; sourceTree = SOURCE_ROOT; };
42 | DF03B9021A382B4B007E23DB /* CollectionHeaderView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CollectionHeaderView.h; path = MONUniformFlowLayoutSample/CollectionHeaderView.h; sourceTree = SOURCE_ROOT; };
43 | DF03B9031A382B4B007E23DB /* CollectionHeaderView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = CollectionHeaderView.m; path = MONUniformFlowLayoutSample/CollectionHeaderView.m; sourceTree = SOURCE_ROOT; };
44 | DF03B9041A382B4B007E23DB /* CollectionViewCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CollectionViewCell.h; path = MONUniformFlowLayoutSample/CollectionViewCell.h; sourceTree = SOURCE_ROOT; };
45 | DF03B9051A382B4B007E23DB /* CollectionViewCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = CollectionViewCell.m; path = MONUniformFlowLayoutSample/CollectionViewCell.m; sourceTree = SOURCE_ROOT; };
46 | DF03B9061A382B4B007E23DB /* default.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; name = default.json; path = MONUniformFlowLayoutSample/default.json; sourceTree = SOURCE_ROOT; };
47 | DF03B9071A382B4B007E23DB /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; name = Images.xcassets; path = MONUniformFlowLayoutSample/Images.xcassets; sourceTree = SOURCE_ROOT; };
48 | DF03B9081A382B4B007E23DB /* InputViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = InputViewController.h; path = MONUniformFlowLayoutSample/InputViewController.h; sourceTree = SOURCE_ROOT; };
49 | DF03B9091A382B4B007E23DB /* InputViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = InputViewController.m; path = MONUniformFlowLayoutSample/InputViewController.m; sourceTree = SOURCE_ROOT; };
50 | DF03B90A1A382B4B007E23DB /* ViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ViewController.h; path = MONUniformFlowLayoutSample/ViewController.h; sourceTree = SOURCE_ROOT; };
51 | DF03B90B1A382B4B007E23DB /* ViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = ViewController.m; path = MONUniformFlowLayoutSample/ViewController.m; sourceTree = SOURCE_ROOT; };
52 | DF03B9151A382B5E007E23DB /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = MONUniformFlowLayoutSample/Base.lproj/LaunchScreen.xib; sourceTree = SOURCE_ROOT; };
53 | DF03B9171A382B94007E23DB /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = Info.plist; path = MONUniformFlowLayoutSample/Info.plist; sourceTree = SOURCE_ROOT; };
54 | DF03B9181A382B94007E23DB /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = main.m; path = MONUniformFlowLayoutSample/main.m; sourceTree = SOURCE_ROOT; };
55 | DF03B91B1A382D49007E23DB /* Dummy.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Dummy.m; sourceTree = ""; };
56 | DF7F16B21A2D86CD00EF7DB4 /* MONUniformFlowLayoutSample.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = MONUniformFlowLayoutSample.app; sourceTree = BUILT_PRODUCTS_DIR; };
57 | DF7F16CB1A2D86CD00EF7DB4 /* MONUniformFlowLayoutSampleTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = MONUniformFlowLayoutSampleTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
58 | /* End PBXFileReference section */
59 |
60 | /* Begin PBXFrameworksBuildPhase section */
61 | DF7F16AF1A2D86CD00EF7DB4 /* Frameworks */ = {
62 | isa = PBXFrameworksBuildPhase;
63 | buildActionMask = 2147483647;
64 | files = (
65 | );
66 | runOnlyForDeploymentPostprocessing = 0;
67 | };
68 | DF7F16C81A2D86CD00EF7DB4 /* Frameworks */ = {
69 | isa = PBXFrameworksBuildPhase;
70 | buildActionMask = 2147483647;
71 | files = (
72 | );
73 | runOnlyForDeploymentPostprocessing = 0;
74 | };
75 | /* End PBXFrameworksBuildPhase section */
76 |
77 | /* Begin PBXGroup section */
78 | DF03B8F51A3828E1007E23DB /* MONUniformFlowLayout */ = {
79 | isa = PBXGroup;
80 | children = (
81 | DF03B8F61A3828E1007E23DB /* MONUniformFlowLayout.h */,
82 | DF03B8F71A3828E1007E23DB /* MONUniformFlowLayout.m */,
83 | );
84 | path = MONUniformFlowLayout;
85 | sourceTree = SOURCE_ROOT;
86 | };
87 | DF03B8F91A382B19007E23DB /* MONUniformFlowLayoutSampleTests */ = {
88 | isa = PBXGroup;
89 | children = (
90 | DF03B8FA1A382B19007E23DB /* Info.plist */,
91 | DF03B91B1A382D49007E23DB /* Dummy.m */,
92 | );
93 | path = MONUniformFlowLayoutSampleTests;
94 | sourceTree = "";
95 | };
96 | DF7F16A91A2D86CD00EF7DB4 = {
97 | isa = PBXGroup;
98 | children = (
99 | DF7F16B41A2D86CD00EF7DB4 /* MONUniformFlowLayoutSample */,
100 | DF03B8F91A382B19007E23DB /* MONUniformFlowLayoutSampleTests */,
101 | DF7F16B31A2D86CD00EF7DB4 /* Products */,
102 | );
103 | sourceTree = "";
104 | };
105 | DF7F16B31A2D86CD00EF7DB4 /* Products */ = {
106 | isa = PBXGroup;
107 | children = (
108 | DF7F16B21A2D86CD00EF7DB4 /* MONUniformFlowLayoutSample.app */,
109 | DF7F16CB1A2D86CD00EF7DB4 /* MONUniformFlowLayoutSampleTests.xctest */,
110 | );
111 | name = Products;
112 | sourceTree = "";
113 | };
114 | DF7F16B41A2D86CD00EF7DB4 /* MONUniformFlowLayoutSample */ = {
115 | isa = PBXGroup;
116 | children = (
117 | DF03B8FE1A382B4B007E23DB /* AppDelegate.h */,
118 | DF03B8FF1A382B4B007E23DB /* AppDelegate.m */,
119 | DF03B9001A382B4B007E23DB /* CollectionFooterView.h */,
120 | DF03B9011A382B4B007E23DB /* CollectionFooterView.m */,
121 | DF03B9021A382B4B007E23DB /* CollectionHeaderView.h */,
122 | DF03B9031A382B4B007E23DB /* CollectionHeaderView.m */,
123 | DF03B9041A382B4B007E23DB /* CollectionViewCell.h */,
124 | DF03B9051A382B4B007E23DB /* CollectionViewCell.m */,
125 | DF03B9061A382B4B007E23DB /* default.json */,
126 | DF03B9071A382B4B007E23DB /* Images.xcassets */,
127 | DF03B9081A382B4B007E23DB /* InputViewController.h */,
128 | DF03B9091A382B4B007E23DB /* InputViewController.m */,
129 | DF03B9141A382B5E007E23DB /* LaunchScreen.xib */,
130 | DF03B8F51A3828E1007E23DB /* MONUniformFlowLayout */,
131 | DF7F16B51A2D86CD00EF7DB4 /* Supporting Files */,
132 | DF03B90A1A382B4B007E23DB /* ViewController.h */,
133 | DF03B90B1A382B4B007E23DB /* ViewController.m */,
134 | );
135 | name = MONUniformFlowLayoutSample;
136 | path = CollectionSample;
137 | sourceTree = "";
138 | };
139 | DF7F16B51A2D86CD00EF7DB4 /* Supporting Files */ = {
140 | isa = PBXGroup;
141 | children = (
142 | DF03B9171A382B94007E23DB /* Info.plist */,
143 | DF03B9181A382B94007E23DB /* main.m */,
144 | );
145 | name = "Supporting Files";
146 | sourceTree = "";
147 | };
148 | /* End PBXGroup section */
149 |
150 | /* Begin PBXNativeTarget section */
151 | DF7F16B11A2D86CD00EF7DB4 /* MONUniformFlowLayoutSample */ = {
152 | isa = PBXNativeTarget;
153 | buildConfigurationList = DF7F16D51A2D86CD00EF7DB4 /* Build configuration list for PBXNativeTarget "MONUniformFlowLayoutSample" */;
154 | buildPhases = (
155 | DF7F16AE1A2D86CD00EF7DB4 /* Sources */,
156 | DF7F16AF1A2D86CD00EF7DB4 /* Frameworks */,
157 | DF7F16B01A2D86CD00EF7DB4 /* Resources */,
158 | );
159 | buildRules = (
160 | );
161 | dependencies = (
162 | );
163 | name = MONUniformFlowLayoutSample;
164 | productName = CollectionSample;
165 | productReference = DF7F16B21A2D86CD00EF7DB4 /* MONUniformFlowLayoutSample.app */;
166 | productType = "com.apple.product-type.application";
167 | };
168 | DF7F16CA1A2D86CD00EF7DB4 /* MONUniformFlowLayoutSampleTests */ = {
169 | isa = PBXNativeTarget;
170 | buildConfigurationList = DF7F16D81A2D86CD00EF7DB4 /* Build configuration list for PBXNativeTarget "MONUniformFlowLayoutSampleTests" */;
171 | buildPhases = (
172 | DF7F16C71A2D86CD00EF7DB4 /* Sources */,
173 | DF7F16C81A2D86CD00EF7DB4 /* Frameworks */,
174 | DF7F16C91A2D86CD00EF7DB4 /* Resources */,
175 | );
176 | buildRules = (
177 | );
178 | dependencies = (
179 | DF7F16CD1A2D86CD00EF7DB4 /* PBXTargetDependency */,
180 | );
181 | name = MONUniformFlowLayoutSampleTests;
182 | productName = CollectionSampleTests;
183 | productReference = DF7F16CB1A2D86CD00EF7DB4 /* MONUniformFlowLayoutSampleTests.xctest */;
184 | productType = "com.apple.product-type.bundle.unit-test";
185 | };
186 | /* End PBXNativeTarget section */
187 |
188 | /* Begin PBXProject section */
189 | DF7F16AA1A2D86CD00EF7DB4 /* Project object */ = {
190 | isa = PBXProject;
191 | attributes = {
192 | LastUpgradeCheck = 0610;
193 | ORGANIZATIONNAME = mownier;
194 | TargetAttributes = {
195 | DF7F16B11A2D86CD00EF7DB4 = {
196 | CreatedOnToolsVersion = 6.1;
197 | };
198 | DF7F16CA1A2D86CD00EF7DB4 = {
199 | CreatedOnToolsVersion = 6.1;
200 | TestTargetID = DF7F16B11A2D86CD00EF7DB4;
201 | };
202 | };
203 | };
204 | buildConfigurationList = DF7F16AD1A2D86CD00EF7DB4 /* Build configuration list for PBXProject "MONUniformFlowLayoutSample" */;
205 | compatibilityVersion = "Xcode 3.2";
206 | developmentRegion = English;
207 | hasScannedForEncodings = 0;
208 | knownRegions = (
209 | en,
210 | Base,
211 | );
212 | mainGroup = DF7F16A91A2D86CD00EF7DB4;
213 | productRefGroup = DF7F16B31A2D86CD00EF7DB4 /* Products */;
214 | projectDirPath = "";
215 | projectRoot = "";
216 | targets = (
217 | DF7F16B11A2D86CD00EF7DB4 /* MONUniformFlowLayoutSample */,
218 | DF7F16CA1A2D86CD00EF7DB4 /* MONUniformFlowLayoutSampleTests */,
219 | );
220 | };
221 | /* End PBXProject section */
222 |
223 | /* Begin PBXResourcesBuildPhase section */
224 | DF7F16B01A2D86CD00EF7DB4 /* Resources */ = {
225 | isa = PBXResourcesBuildPhase;
226 | buildActionMask = 2147483647;
227 | files = (
228 | DF03B91D1A382EA8007E23DB /* LaunchScreen.xib in Resources */,
229 | DF03B9111A382B4B007E23DB /* Images.xcassets in Resources */,
230 | DF03B9101A382B4B007E23DB /* default.json in Resources */,
231 | );
232 | runOnlyForDeploymentPostprocessing = 0;
233 | };
234 | DF7F16C91A2D86CD00EF7DB4 /* Resources */ = {
235 | isa = PBXResourcesBuildPhase;
236 | buildActionMask = 2147483647;
237 | files = (
238 | );
239 | runOnlyForDeploymentPostprocessing = 0;
240 | };
241 | /* End PBXResourcesBuildPhase section */
242 |
243 | /* Begin PBXSourcesBuildPhase section */
244 | DF7F16AE1A2D86CD00EF7DB4 /* Sources */ = {
245 | isa = PBXSourcesBuildPhase;
246 | buildActionMask = 2147483647;
247 | files = (
248 | DF03B9121A382B4B007E23DB /* InputViewController.m in Sources */,
249 | DF03B90F1A382B4B007E23DB /* CollectionViewCell.m in Sources */,
250 | DF03B9131A382B4B007E23DB /* ViewController.m in Sources */,
251 | DF03B8F81A3828E1007E23DB /* MONUniformFlowLayout.m in Sources */,
252 | DF03B90C1A382B4B007E23DB /* AppDelegate.m in Sources */,
253 | DF03B90D1A382B4B007E23DB /* CollectionFooterView.m in Sources */,
254 | DF03B91A1A382B94007E23DB /* main.m in Sources */,
255 | DF03B90E1A382B4B007E23DB /* CollectionHeaderView.m in Sources */,
256 | );
257 | runOnlyForDeploymentPostprocessing = 0;
258 | };
259 | DF7F16C71A2D86CD00EF7DB4 /* Sources */ = {
260 | isa = PBXSourcesBuildPhase;
261 | buildActionMask = 2147483647;
262 | files = (
263 | DF03B91C1A382D49007E23DB /* Dummy.m in Sources */,
264 | );
265 | runOnlyForDeploymentPostprocessing = 0;
266 | };
267 | /* End PBXSourcesBuildPhase section */
268 |
269 | /* Begin PBXTargetDependency section */
270 | DF7F16CD1A2D86CD00EF7DB4 /* PBXTargetDependency */ = {
271 | isa = PBXTargetDependency;
272 | target = DF7F16B11A2D86CD00EF7DB4 /* MONUniformFlowLayoutSample */;
273 | targetProxy = DF7F16CC1A2D86CD00EF7DB4 /* PBXContainerItemProxy */;
274 | };
275 | /* End PBXTargetDependency section */
276 |
277 | /* Begin PBXVariantGroup section */
278 | DF03B9141A382B5E007E23DB /* LaunchScreen.xib */ = {
279 | isa = PBXVariantGroup;
280 | children = (
281 | DF03B9151A382B5E007E23DB /* Base */,
282 | );
283 | name = LaunchScreen.xib;
284 | sourceTree = "";
285 | };
286 | /* End PBXVariantGroup section */
287 |
288 | /* Begin XCBuildConfiguration section */
289 | DF7F16D31A2D86CD00EF7DB4 /* Debug */ = {
290 | isa = XCBuildConfiguration;
291 | buildSettings = {
292 | ALWAYS_SEARCH_USER_PATHS = NO;
293 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
294 | CLANG_CXX_LIBRARY = "libc++";
295 | CLANG_ENABLE_MODULES = YES;
296 | CLANG_ENABLE_OBJC_ARC = YES;
297 | CLANG_WARN_BOOL_CONVERSION = YES;
298 | CLANG_WARN_CONSTANT_CONVERSION = YES;
299 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
300 | CLANG_WARN_EMPTY_BODY = YES;
301 | CLANG_WARN_ENUM_CONVERSION = YES;
302 | CLANG_WARN_INT_CONVERSION = YES;
303 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
304 | CLANG_WARN_UNREACHABLE_CODE = YES;
305 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
306 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
307 | COPY_PHASE_STRIP = NO;
308 | ENABLE_STRICT_OBJC_MSGSEND = YES;
309 | GCC_C_LANGUAGE_STANDARD = gnu99;
310 | GCC_DYNAMIC_NO_PIC = NO;
311 | GCC_OPTIMIZATION_LEVEL = 0;
312 | GCC_PREPROCESSOR_DEFINITIONS = (
313 | "DEBUG=1",
314 | "$(inherited)",
315 | );
316 | GCC_SYMBOLS_PRIVATE_EXTERN = NO;
317 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
318 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
319 | GCC_WARN_UNDECLARED_SELECTOR = YES;
320 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
321 | GCC_WARN_UNUSED_FUNCTION = YES;
322 | GCC_WARN_UNUSED_VARIABLE = YES;
323 | IPHONEOS_DEPLOYMENT_TARGET = 8.1;
324 | MTL_ENABLE_DEBUG_INFO = YES;
325 | ONLY_ACTIVE_ARCH = YES;
326 | SDKROOT = iphoneos;
327 | };
328 | name = Debug;
329 | };
330 | DF7F16D41A2D86CD00EF7DB4 /* Release */ = {
331 | isa = XCBuildConfiguration;
332 | buildSettings = {
333 | ALWAYS_SEARCH_USER_PATHS = NO;
334 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
335 | CLANG_CXX_LIBRARY = "libc++";
336 | CLANG_ENABLE_MODULES = YES;
337 | CLANG_ENABLE_OBJC_ARC = YES;
338 | CLANG_WARN_BOOL_CONVERSION = YES;
339 | CLANG_WARN_CONSTANT_CONVERSION = YES;
340 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
341 | CLANG_WARN_EMPTY_BODY = YES;
342 | CLANG_WARN_ENUM_CONVERSION = YES;
343 | CLANG_WARN_INT_CONVERSION = YES;
344 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
345 | CLANG_WARN_UNREACHABLE_CODE = YES;
346 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
347 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
348 | COPY_PHASE_STRIP = YES;
349 | ENABLE_NS_ASSERTIONS = NO;
350 | ENABLE_STRICT_OBJC_MSGSEND = YES;
351 | GCC_C_LANGUAGE_STANDARD = gnu99;
352 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
353 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
354 | GCC_WARN_UNDECLARED_SELECTOR = YES;
355 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
356 | GCC_WARN_UNUSED_FUNCTION = YES;
357 | GCC_WARN_UNUSED_VARIABLE = YES;
358 | IPHONEOS_DEPLOYMENT_TARGET = 8.1;
359 | MTL_ENABLE_DEBUG_INFO = NO;
360 | SDKROOT = iphoneos;
361 | VALIDATE_PRODUCT = YES;
362 | };
363 | name = Release;
364 | };
365 | DF7F16D61A2D86CD00EF7DB4 /* Debug */ = {
366 | isa = XCBuildConfiguration;
367 | buildSettings = {
368 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
369 | INFOPLIST_FILE = MONUniformFlowLayoutSample/Info.plist;
370 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
371 | PRODUCT_NAME = MONUniformFlowLayoutSample;
372 | };
373 | name = Debug;
374 | };
375 | DF7F16D71A2D86CD00EF7DB4 /* Release */ = {
376 | isa = XCBuildConfiguration;
377 | buildSettings = {
378 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
379 | INFOPLIST_FILE = MONUniformFlowLayoutSample/Info.plist;
380 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
381 | PRODUCT_NAME = MONUniformFlowLayoutSample;
382 | };
383 | name = Release;
384 | };
385 | DF7F16D91A2D86CD00EF7DB4 /* Debug */ = {
386 | isa = XCBuildConfiguration;
387 | buildSettings = {
388 | BUNDLE_LOADER = "$(TEST_HOST)";
389 | FRAMEWORK_SEARCH_PATHS = (
390 | "$(SDKROOT)/Developer/Library/Frameworks",
391 | "$(inherited)",
392 | );
393 | GCC_PREPROCESSOR_DEFINITIONS = (
394 | "DEBUG=1",
395 | "$(inherited)",
396 | );
397 | INFOPLIST_FILE = MONUniformFlowLayoutSampleTests/Info.plist;
398 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
399 | PRODUCT_NAME = MONUniformFlowLayoutSampleTests;
400 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/MONUniformFlowLayoutSample.app/MONUniformFlowLayoutSample";
401 | };
402 | name = Debug;
403 | };
404 | DF7F16DA1A2D86CD00EF7DB4 /* Release */ = {
405 | isa = XCBuildConfiguration;
406 | buildSettings = {
407 | BUNDLE_LOADER = "$(TEST_HOST)";
408 | FRAMEWORK_SEARCH_PATHS = (
409 | "$(SDKROOT)/Developer/Library/Frameworks",
410 | "$(inherited)",
411 | );
412 | INFOPLIST_FILE = MONUniformFlowLayoutSampleTests/Info.plist;
413 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
414 | PRODUCT_NAME = MONUniformFlowLayoutSampleTests;
415 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/MONUniformFlowLayoutSample.app/MONUniformFlowLayoutSample";
416 | };
417 | name = Release;
418 | };
419 | /* End XCBuildConfiguration section */
420 |
421 | /* Begin XCConfigurationList section */
422 | DF7F16AD1A2D86CD00EF7DB4 /* Build configuration list for PBXProject "MONUniformFlowLayoutSample" */ = {
423 | isa = XCConfigurationList;
424 | buildConfigurations = (
425 | DF7F16D31A2D86CD00EF7DB4 /* Debug */,
426 | DF7F16D41A2D86CD00EF7DB4 /* Release */,
427 | );
428 | defaultConfigurationIsVisible = 0;
429 | defaultConfigurationName = Release;
430 | };
431 | DF7F16D51A2D86CD00EF7DB4 /* Build configuration list for PBXNativeTarget "MONUniformFlowLayoutSample" */ = {
432 | isa = XCConfigurationList;
433 | buildConfigurations = (
434 | DF7F16D61A2D86CD00EF7DB4 /* Debug */,
435 | DF7F16D71A2D86CD00EF7DB4 /* Release */,
436 | );
437 | defaultConfigurationIsVisible = 0;
438 | defaultConfigurationName = Release;
439 | };
440 | DF7F16D81A2D86CD00EF7DB4 /* Build configuration list for PBXNativeTarget "MONUniformFlowLayoutSampleTests" */ = {
441 | isa = XCConfigurationList;
442 | buildConfigurations = (
443 | DF7F16D91A2D86CD00EF7DB4 /* Debug */,
444 | DF7F16DA1A2D86CD00EF7DB4 /* Release */,
445 | );
446 | defaultConfigurationIsVisible = 0;
447 | defaultConfigurationName = Release;
448 | };
449 | /* End XCConfigurationList section */
450 | };
451 | rootObject = DF7F16AA1A2D86CD00EF7DB4 /* Project object */;
452 | }
453 |
--------------------------------------------------------------------------------