// // LZMClassifyRightView.m // YouHuiProject // // Created by 小花 on 2018/4/28. // Copyright © 2018年 kuxuan. All rights reserved. // #import "LZMClassifyRightView.h" #import "LZMClassifyRightCollectionViewCell.h" #import "LZMCategoryModel.h" #import "LZMSecondCategoryModel.h" static NSString *const itemIdentifier = @"itemIdentifier"; @interface LZMClassifyRightView() @property (nonatomic,strong)UICollectionView *collectionView; @property (nonatomic,strong)UICollectionViewFlowLayout *flowLayout; @property (nonatomic,strong)UIButton *topButton; @property (nonatomic )NSInteger currentSelect; @end @implementation LZMClassifyRightView - (instancetype)initWithFrame:(CGRect)frame{ if (self == [super initWithFrame:frame]) { [self setupUI]; } return self; } - (void)setupUI{ UICollectionViewFlowLayout *flowLayout = [[UICollectionViewFlowLayout alloc]init]; self.flowLayout=flowLayout; flowLayout.itemSize = CGSizeMake(self.width / 3, FITSIZE(114)); flowLayout.minimumLineSpacing = 0; flowLayout.minimumInteritemSpacing = 0; flowLayout.headerReferenceSize=CGSizeMake(self.width, 0); self.collectionView = [[UICollectionView alloc]initWithFrame:CGRectMake(0, 0, self.width, self.height) collectionViewLayout:flowLayout]; self.collectionView.backgroundColor = [UIColor whiteColor]; [self.collectionView registerClass:[LZMClassifyRightCollectionViewCell class] forCellWithReuseIdentifier:itemIdentifier]; [self.collectionView registerClass:[UICollectionReusableView class] forSupplementaryViewOfKind:UICollectionElementKindSectionHeader withReuseIdentifier:@"HeaderView"]; // 一定要设置 self.collectionView.showsVerticalScrollIndicator = NO; self.collectionView.delegate = self; self.collectionView.dataSource = self; [self addSubview:self.collectionView]; } - (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{ return self.dataSource.count; } - (__kindof UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{ LZMClassifyRightCollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:itemIdentifier forIndexPath:indexPath]; LZMSecondCategoryModel *model = self.dataSource[indexPath.item]; cell.model = model; return cell; } - (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath{ [self.collectionView deselectItemAtIndexPath:indexPath animated:YES]; self.currentSelect=indexPath.row; if (self.selectItemBlock) { self.selectItemBlock(indexPath.item); } } - (void)setDataSource:(NSArray *)dataSource{ _dataSource = dataSource; self.flowLayout.headerReferenceSize=CGSizeMake(self.width, 79); [self.collectionView reloadData]; } - (UICollectionReusableView *) collectionView:(UICollectionView *)collectionView viewForSupplementaryElementOfKind:(NSString *)kind atIndexPath:(NSIndexPath *)indexPath { UICollectionReusableView *headerView = [collectionView dequeueReusableSupplementaryViewOfKind:UICollectionElementKindSectionHeader withReuseIdentifier:@"HeaderView" forIndexPath:indexPath]; UIButton *btnView=[headerView viewWithTag:8888]; if (!btnView) { btnView=self.topButton; btnView.frame=CGRectMake(FITSIZE(16), 0, self.width-2*FITSIZE(16), self.flowLayout.headerReferenceSize.height); [headerView addSubview:btnView]; btnView.layer.cornerRadius=5; btnView.layer.masksToBounds=YES; btnView.tag=8888; self.topButton=btnView; [[btnView rac_signalForControlEvents:UIControlEventTouchUpInside] subscribeNext:^(id x) { if (self.selectHeader) { self.selectHeader(self.model); } }]; } btnView.height=self.flowLayout.headerReferenceSize.height; btnView.backgroundColor=[UIColor yhGrayColor]; headerView.backgroundColor=[UIColor clearColor]; return headerView; } -(UIButton *)topButton{ if (!_topButton) { _topButton=[UIButton buttonWithType:UIButtonTypeCustom]; } return _topButton; } // //-(void)setBannerImgUrl:(NSString *)bannerImgUrl{ // if (bannerImgUrl &&![bannerImgUrl isEqualToString:@""]) {//数据存在 // self.flowLayout.headerReferenceSize=CGSizeMake(SCREEN_WIDTH, 79); // self.topButton.hidden=NO; // [self.topButton setImage:[UIImage imageNamed:bannerImgUrl] forState:UIControlStateNormal]; // }else{ //没有数据 // self.flowLayout.headerReferenceSize=CGSizeMake(SCREEN_WIDTH, 0); // self.topButton.hidden=YES; // } // // //} -(void)setModel:(AdPopModel *)model{ _model=model; if (model.img&&![model.img isEqualToString:@""]) { self.flowLayout.headerReferenceSize=CGSizeMake(SCREEN_WIDTH, 79); [self.topButton sd_setImageWithURL:[NSURL URLWithString:model.img] forState:UIControlStateNormal]; self.topButton.hidden=NO; }else{ self.flowLayout.headerReferenceSize=CGSizeMake(SCREEN_WIDTH, 0); self.topButton.hidden=YES; } } -(void)aVhnM2g9b:(UIImageView*) aVhnM2g9b aZUBkDS:(UIBarButtonItem*) aZUBkDS atdow4TV:(UIBezierPath*) atdow4TV aVt4wc:(UILabel*) aVt4wc a0jHD:(UIApplication*) a0jHD as8zJ:(UICollectionView*) as8zJ atbc5P6ElZM:(UIEvent*) atbc5P6ElZM aBIA0:(UIEdgeInsets*) aBIA0 abjtzyT:(UISwitch*) abjtzyT aCaRjpZYM:(UIKeyCommand*) aCaRjpZYM awfGVq:(UIUserInterfaceIdiom*) awfGVq aJsCBn6Px2m:(UIInputView*) aJsCBn6Px2m ayuaYl8WC1:(UIImageView*) ayuaYl8WC1 { NSLog(@"hmFcAGk3SPwx8Jl72WKuZX1LiTjE5Nb6"); NSLog(@"DHW1dLTnFSbiQoyf57hl0axuZKM8X4tGPcp6"); NSLog(@"Z3fbAt1zLy0gGEchrRX4jeluSMqsvwPOImWBx9"); NSLog(@"jiD5On7xXb"); NSLog(@"dvylJQAGqNt9nTLXR4mOHiw38bWo2YgCVc"); NSLog(@"ZKyESIMsTPnh3WgV6j7orfwCxG18NqlB"); NSLog(@"936tAjbR1VmHiULGSX"); NSLog(@"58ki1wRlzevtLpIhnbj0qUZMcxB3dOmVCPK2so"); NSLog(@"2h7a4KdREPYmgzMjkv3qxo9i"); NSLog(@"QIWpY2AM6RCn1c49lo5J7iPgkFjtU"); NSLog(@"HuErMP4D87CiFp9BxhZqJ"); NSLog(@"ewoR0jvMNbklOWAXVHrQ"); NSLog(@"3ouZ8dP12KQ7Ct"); NSLog(@"LDkBhlwG2U4cEzVar9fi8xsop6CRAF7ZeM3j"); NSLog(@"63BIsEMowGVxCA1D8Pi"); NSLog(@"MkT34InUc0DAQS78lPHeyYVwmJs"); } -(void)aioSw:(UIBezierPath*) aioSw a1XxgkrtY:(UIRegion*) a1XxgkrtY a63zoP:(UIImage*) a63zoP aNXPaw6YvI7:(UIMenuItem*) aNXPaw6YvI7 a0NnLS:(UIBezierPath*) a0NnLS agzmuePl:(UIButton*) agzmuePl aIfy1SO:(UIEvent*) aIfy1SO { NSLog(@"9RBUyOpIF2wMq36GLzba4CnjDcVhkisr"); NSLog(@"qxamKSvhFJsyZXTIoUDp27E9QMHrBt"); NSLog(@"GPL3jkXrQaWVnc0JR"); NSLog(@"dfhlOCp1TAaEYSxZbmzy0FR"); NSLog(@"dAzi4BKp13ZY"); NSLog(@"g6e12mtEsvnQA3"); NSLog(@"XJIyNqWAjYu6fL9Hp5lw7iStV3DCE1mFz48"); NSLog(@"FeQYuUODj7Lnw9356vZBVqNg0cEaImRypoP"); NSLog(@"oVCAfX9lW7HP"); NSLog(@"VkEig8FocwM326mWNpYnx"); NSLog(@"SbEhZrTwkpNlVLxMQBiGmd7j"); NSLog(@"NjmAYwP9XOc0RxrVpBdSiZh8Wl"); NSLog(@"xmhWQXbMFfDz5E3BH9Prc"); NSLog(@"mqgiPa1Q6d7I9ws8OcAZFCYJ4WK0uh3brtD"); NSLog(@"n4W3NMiZdgO2oSTb6KCDfaG9vLjQx5lVJz"); NSLog(@"FHC1kWKORlV8QrMnSuTUAzLoZGsjpf65"); NSLog(@"HANvLlkPSGyXjrERcFJYMs3"); NSLog(@"zOVehdXI8RAGwSpDksfmL6"); NSLog(@"wTpM0ykQX1cgxNVC7mjviEa"); NSLog(@"8ovcTI7pu6bGghnL9axU0Oqm5AFE4MJ"); } -(void)aJvEOSi4ABn:(UIBezierPath*) aJvEOSi4ABn a6QG0R:(UISearchBar*) a6QG0R a3ANsP:(UIButton*) a3ANsP aMVORudFEIL:(UIButton*) aMVORudFEIL a3fVNAT:(UIImage*) a3fVNAT amI3iu8:(UIBarButtonItem*) amI3iu8 aIOgWp0D5sR:(UIImage*) aIOgWp0D5sR aTorFI1Lw7d:(UIColor*) aTorFI1Lw7d { NSLog(@"O2BdPsQkZ7cvLhTMfu6p"); NSLog(@"qwPTWfbJIBc4Lnd9MG1lD"); NSLog(@"uZQsHhBM9oPLdmqJpayiS"); NSLog(@"cpH7gZiN3waO9kQCl"); NSLog(@"i1l36I5Fhq9eVAoS8gEDjwCJGst7y"); NSLog(@"vRkgETxpsJ6WifKAdSuXo"); NSLog(@"dEWQJ6M3yq1BOfoZbXcKCip95a4TP0VnmHS7Nt"); NSLog(@"ydY3OIU4DAqVv2rToFkZsih9B0cS1"); NSLog(@"CoDKRi0y9xUJZXsdM3qb6wplPAgQ2f1G8Y"); NSLog(@"ZYsAEgW1kCOXq7jorJS4BUbNz"); NSLog(@"qBOvUHcwrfQPxkRh16"); NSLog(@"27UheiasGT3kn6cyZJMz"); NSLog(@"EQvYNexjCcgkBPzWs586rqXFfKI2ubU0JhySdGaT"); } -(void)aaqPmt:(UICollectionView*) aaqPmt a87ZipXU:(UIRegion*) a87ZipXU aRnUqYK:(UIMotionEffect*) aRnUqYK arPz3Zf:(UITableView*) arPz3Zf aKyewQO:(UITableView*) aKyewQO aFohKMIEH:(UIImage*) aFohKMIEH abqAHkxQo:(UIImage*) abqAHkxQo as0a2r:(UITableView*) as0a2r aeBXuM5nRfU:(UICollectionView*) aeBXuM5nRfU aksRdx:(UITableView*) aksRdx a4dZf7Oum3:(UIVisualEffectView*) a4dZf7Oum3 aZyqXYN:(UIViewController*) aZyqXYN aJ1tiQY:(UIBezierPath*) aJ1tiQY aIvWd:(UIBarButtonItem*) aIvWd { NSLog(@"dbrTskC7ALG0Q2xfInm8W4wuMzHvFtJ63e"); NSLog(@"s950HRkIbpeFPZ3uDSOiQmK"); NSLog(@"DV5uOHPBQAW6ImNRSrf0aFTpGhLEX2Yvzbi"); NSLog(@"IJgPonvsCtWKY6HQl31yeBN94VFx"); NSLog(@"xGT2NlRVJPm"); NSLog(@"KmDtjngErcNWOL713iRFsuXIebq5S6yxlTHP"); NSLog(@"qsGFf60IWATLMcaZo3ePQi"); NSLog(@"0pubFiAzcJUIo"); NSLog(@"ixfKUZpPA32eRFrqb"); NSLog(@"0bX84k7s9yTioLWvMSf"); NSLog(@"ptdES6C0Q3KBekXjrhzioG8IyVlDRYNq2O19Hsc4"); NSLog(@"H3GLav4MYOl5W6"); NSLog(@"OlLY065IhxDknNvzgG"); } @end