-(UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
if (style ==1) {
KeepCarBrandCollectionViewCell *cell = (KeepCarBrandCollectionViewCell *)[collectionView dequeueReusableCellWithReuseIdentifier:@"KeepCarBrandCollectionViewCell" forIndexPath:indexPath];
[cell setBackgroundColor:kYellowColor];
NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"%@%@",kImageBaseURL,_imageArray[indexPath.row]]];
[cell.iconImageView setImageWithURL:url placeholderImage:[UIImage imageNamed:@"pic_common_carlogo_loading"]];
NSLog(@"%@",url);
[cell.iconImageView setContentMode:UIViewContentModeScaleAspectFit];
[cell.brandNameLabel setText:_titleArray[indexPath.row]];
return cell;
}else if (style == 2)
{
UICollectionViewCell *cell = (UICollectionViewCell *)[collectionView dequeueReusableCellWithReuseIdentifier:@"CarTypeCell" forIndexPath:indexPath];
if (cell) {
[cell.subviews makeObjectsPerformSelector:@selector(removeFromSuperview)];
}
//边框view
UIView *borderView = [[UIView alloc] initWithFrame:CGRectMake(5, 5, cell.width-10, cell.height-10)];
[borderView setBorder:1 color:kLineColor];
[cell addSubview:borderView];
//内容label
UILabel *contentLabel = [[UILabel alloc] initWithFrame:borderView.frame];
contentLabel.font = FONT(16);
if (_headerArray[indexPath.section]) {
contentLabel.text = [[_contentDic objectForKey:[_headerArray[indexPath.section] objectForKey:@"id"]][indexPath.row] objectForKey:@"name"];
}
contentLabel.textAlignment = NSTextAlignmentCenter;
[cell addSubview:contentLabel];
return cell;
}else if (style ==3)
{
UICollectionViewCell *cell = (UICollectionViewCell *)[collectionView dequeueReusableCellWithReuseIdentifier:@"OutPutCell" forIndexPath:indexPath];
if (cell) {
[cell.subviews makeObjectsPerformSelector:@selector(removeFromSuperview)];
}
//边框view
UIView *borderView = [[UIView alloc] initWithFrame:CGRectMake(5, 5, cell.width-10, cell.height-10)];
[borderView setBorder:1 color:kLineColor];
[cell addSubview:borderView];
//内容label
UILabel *contentLabel = [[UILabel alloc] initWithFrame:borderView.frame];
contentLabel.font = FONT(16);
contentLabel.text = _contentArray[indexPath.row];
contentLabel.textAlignment = NSTextAlignmentCenter;
[cell addSubview:contentLabel];
return cell;
}
return nil;
}
|