-
Notifications
You must be signed in to change notification settings - Fork 9
/
OUHomeView.m
34 lines (29 loc) · 1.25 KB
/
OUHomeView.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
//
// OUHomeView.m
// GWL
//
// Created by oujinlong on 16/6/1.
// Copyright © 2016年 oujinlong. All rights reserved.
//
#import "OUHomeView.h"
@class FilmCollectionViewCell;
@implementation OUHomeView
-(instancetype)initWithFrame:(CGRect)frame dataSource:(id<UICollectionViewDataSource>)dataSource delegate:(id<UICollectionViewDelegate>)delegate{
UICollectionViewFlowLayout* layout = [[UICollectionViewFlowLayout alloc] init];
if (self = [super initWithFrame:frame collectionViewLayout:layout]) {
CGFloat panding = 15;
NSInteger numberOfCol = 3;
CGFloat width = ([UIScreen mainScreen].bounds.size.width - (numberOfCol + 1) * panding)/numberOfCol;
self.backgroundColor = [UIColor colorWithRed:235/255.0 green:235/255.0 blue:235/255.0 alpha:1];
CGFloat heignt = 1.7 * width;
self.dataSource = dataSource;
self.delegate = delegate;
layout.itemSize = CGSizeMake(width, heignt);
layout.minimumInteritemSpacing = panding;
layout.minimumLineSpacing = 20;
layout.sectionInset = UIEdgeInsetsMake(0, panding, 0, panding);
[self registerNib:[UINib nibWithNibName:@"FilmCollectionViewCell" bundle:nil] forCellWithReuseIdentifier:@"cell"];
}
return self;
}
@end