cdh

CDHorizontalScrollView

横向滚动视图, 其实是对collectionView的简单封装, 方便使用 可以自定义cell, (纯代码, Xib都行)简单快捷, 详见Demo

Showing:

Popularity

Downloads/wk

0

GitHub Stars

84

Maintenance

Last Commit

2yrs ago

Contributors

0

Package

Dependencies

1

License

MIT

Categories

Readme

CDHorizontalScrollView

  • CDHorizontalScrollView 支持UICollectionView, UITableView等控件添加横向滚动的视图
展示图

Requirements

  • Xcode 7 or higher
  • iOS 8.0 or higher
  • ARC
pod 'CDHorizontalScrollView'

使用方法


#import "CDHorizontalScrollView.h"

@property (nonatomic, strong) CDHorizontalScrollView *horizontalScrollView;
@property (nonatomic, strong) NSArray *array;

- (void)setupView {

    [self.contentView addSubview:self.horizontalScrollView];

    self.array = @[@"text1", @"text2", @"text3", @"text4", @"text5", @"text6", @"text7", @"text8", @"text9"];
    [self.horizontalScrollView reloadData];
}


#pragma mark - CDHorizontalScrollViewDelegate
- (NSArray *)numberOfColumnsInCollectionView:(CDHorizontalScrollView *)collectionView {

    return [self.array copy];
}

//每个item大小
- (CGSize)cellSizeForItemAtIndexPath:(NSIndexPath *)indexPath {

    return CGSizeMake(floor(CDREALVALUE_WIDTH(160.0)), floor(CDREALVALUE_HEIGHT(216.0)));
}
//上左下右
- (UIEdgeInsets)collectionViewInsetForSectionAtIndex:(NSInteger)section {
    return UIEdgeInsetsMake(CDREALVALUE_HEIGHT(8), CDREALVALUE_WIDTH(16), CDREALVALUE_HEIGHT(8), CDREALVALUE_WIDTH(16));
}
//每个item之间的间距
- (CGFloat)collectionViewMinimumInteritemSpacingForSectionAtIndex:(NSInteger)section {
    return CDREALVALUE_WIDTH(16);
}

- (void)didselectItemAtIndexPath:(NSIndexPath *)indexPath {

}

#pragma mark - Setter Getter Methods
- (CDHorizontalScrollView *)horizontalScrollView {
    if (!_horizontalScrollView) {
        _horizontalScrollView = [[CDHorizontalScrollView alloc] initWithFrame:CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, CGRectGetHeight(self.frame)) withClassCell:[HomeHorizontalCollectionViewCell class] withDelegate:self];
    }
    return _horizontalScrollView;
}

License

CDHorizontalScrollView is available under the MIT license. See the LICENSE file for more info.

Rate & Review

Great Documentation0
Easy to Use0
Performant0
Highly Customizable0
Bleeding Edge0
Responsive Maintainers0
Poor Documentation0
Hard to Use0
Slow0
Buggy0
Abandoned0
Unwelcoming Community0
100
No reviews found
Be the first to rate

Alternatives

No alternatives found

Tutorials

No tutorials found
Add a tutorial