ProductLibraryViewController.m 3.51 KB
Newer Older
曹云霄's avatar
曹云霄 committed
1
//
2
//  ProductLibraryViewController.m
曹云霄's avatar
曹云霄 committed
3 4
//  Lighting
//
5
//  Created by 曹云霄 on 16/5/4.
曹云霄's avatar
曹云霄 committed
6 7 8
//  Copyright © 2016年 上海勾芒科技有限公司. All rights reserved.
//

9
#import "ProductLibraryViewController.h"
曹云霄's avatar
曹云霄 committed
10
#import "ProductCollectionViewCell.h"
曹云霄's avatar
曹云霄 committed
11 12 13 14 15
#import "ProductDetailsViewController.h"




曹云霄's avatar
曹云霄 committed
16

曹云霄's avatar
曹云霄 committed
17
@interface ProductLibraryViewController ()<UICollectionViewDelegate,UICollectionViewDataSource>
曹云霄's avatar
曹云霄 committed
18 19 20

@end

21
@implementation ProductLibraryViewController
曹云霄's avatar
曹云霄 committed
22 23 24 25

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
26
    self.view.backgroundColor = [UIColor blueColor];
曹云霄's avatar
曹云霄 committed
27 28 29
    
    [self uiConfigAction];
    
曹云霄's avatar
曹云霄 committed
30 31
}

曹云霄's avatar
曹云霄 committed
32 33 34 35 36 37 38 39
#pragma mark -布局
- (void)uiConfigAction
{
    self.productCollectionLayout.itemSize = CGSizeMake((ScreenWidth-100)/3, (ScreenWidth-100)/3);
    self.productCollectionLayout.sectionInset = UIEdgeInsetsMake(20, 30, 20, 30);
    self.productCollectionLayout.minimumLineSpacing = 20;
    self.productCollectionLayout.minimumInteritemSpacing = 20;
    self.productCollectionView.dataSource = self;
曹云霄's avatar
曹云霄 committed
40
    self.productCollectionView.delegate = self;
曹云霄's avatar
曹云霄 committed
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85
    
    [self CreatescreeningButton];
}



#pragma mark -筛选按钮
- (void)CreatescreeningButton
{
    UIButton *screeningbutton = [UIButton buttonWithType:UIButtonTypeSystem];
    screeningbutton.frame = CGRectMake(ScreenWidth-100, ScreenHeight*6/10, 50, 50);
    
    //阴影层
    CALayer *layer = [CALayer layer];
    layer.frame = CGRectMake(ScreenWidth-97.5, ScreenHeight*6/10+2.5, 45, 45);//保证layer的size比筛选按钮高宽都短5像素
    layer.backgroundColor = [UIColor blackColor].CGColor;
    layer.shadowOffset = CGSizeMake(0, 8);
    layer.shadowOpacity = 0.7;
    layer.cornerRadius = 25;
    [self.view.layer addSublayer:layer];
    
    //筛选按钮
    screeningbutton.layer.masksToBounds = YES;
    screeningbutton.layer.cornerRadius = 25;
    [screeningbutton setTitle:@"筛选" forState:UIControlStateNormal];
    screeningbutton.titleLabel.font = [UIFont systemFontOfSize:15];
    [screeningbutton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [screeningbutton setTitleColor:kMainBlueColor forState:UIControlStateSelected];
    screeningbutton.backgroundColor = kMainBlueColor;
    [self.view addSubview:screeningbutton];
    
}


- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
    ProductCollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"productcell" forIndexPath:indexPath];
    return cell;
}

- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
{
    return 20;
}

曹云霄's avatar
曹云霄 committed
86 87 88 89 90 91 92
- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath
{
    
    UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"StoryboardwithCYX" bundle:nil];
    ProductDetailsViewController *productDetails = [storyboard instantiateViewControllerWithIdentifier:@"productdetails"];
    [self.navigationController pushViewController:productDetails animated:YES];
}
曹云霄's avatar
曹云霄 committed
93 94 95 96 97 98 99 100 101 102 103 104 105













曹云霄's avatar
曹云霄 committed
106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end