ctionViewLayout *)collectionViewLayout minimumInteritemSpacingForSectionAtIndex:(NSInteger)section{
return _margin_space;
}
- (UIEdgeInsets)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout insetForSectionAtIndex:(NSInteger)section{
return UIEdgeInsetsMake(_margin_top, _margin_left, _margin_bottom, _margin_right);
}
//item大小
- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath{
NSNumber *number = self.widthsArray[indexPath.row];
return CGSizeMake([number floatValue],30);
}
- (__kindof UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{
XKCollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"XKCollectionViewCell" forIndexPath:indexPath];
NSString *title = _titleArray[indexPath.row];
cell.title = title;
if (indexPath.row == _selectIndex) {
cell.isSelectd = YES;
}
else{
cell.isSelectd = NO;
}
return cell;
}
- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath{
_selectString = _titleArray[indexPath.row];
[self updateSelectSeg];
}
#pragma mark ========== 变量 ==========
- (UIView *)lineView{
if(!_lineView){
_lineView = [[UIView alloc]init];
_lineView.backgroundColor = [UIColor purpleColor];
_lineView.layer.masksToBounds = YES;
_lineView.layer.cornerRadius = _line_height/2;
}
return _lineView;
}
@end
|