美文网首页
YJBannerView 的使用方法 (iOS 11 适配)

YJBannerView 的使用方法 (iOS 11 适配)

作者: Bytesking | 来源:发表于2017-07-27 10:09 被阅读0次
    • 使用简单、功能丰富的 Objective-C版 轮播控件, 基于 UICollectionView 实现, 多种场景均支持使用.
    • 源码地址: YJBannerView

    Effect

    image.png

    Features

    • 支持自带PageControl样式配置, 也支持自定义
    • 支持上、下、左、右四个方向自动、手动动滚动
    • 支持自动滚动时间设置
    • 支持首尾循环滚动的开关
    • 支持滚动相关手势的开关
    • 支持ContentMode的设置
    • 支持Banner标题的设置自定义
    • 支持自定义UICollectionViewCell
    • 支持自定义 UIView 填充BannerView
    • 支持在Storyboard\xib中创建并配置其属性
    • 支持非首尾循环的Footer样式和进入详情回调
    • 不依赖其他三方SDWebImage或者AFNetworking设置图片
    • 支持CocoaPods
    • 支持Carthage

    Installation

    Cocoapods

    YJBannerView is available through CocoaPods. To install it, simply add the following line to your Podfile:

        pod 'YJBannerView'
    

    Carthage

        github "YJManager/YJBannerViewOC"
    

    Usage

    1.创建BannerView:

    -(YJBannerView *)normalBannerView{
        if (!_normalBannerView) {
            _normalBannerView = [YJBannerView bannerViewWithFrame:CGRectMake(0, 20, kSCREEN_WIDTH, 180) dataSource:self delegate:self placeholderImageName:@"placeholder" selectorString:@"sd_setImageWithURL:placeholderImage:"];
            _normalBannerView.pageControlAliment = PageControlAlimentRight;
            _normalBannerView.autoDuration = 2.5f;
        }
        return _normalBannerView;
    }
    

    2.实现数据源方法和代理:

    // 将网络图片或者本地图片 或者混合数组
    - (NSArray *)bannerViewImages:(YJBannerView *)bannerView{
        return self.imageDataSources;
    }
    
    // 将标题对应数组传递给bannerView 如果不需要, 可以不实现该方法
    - (NSArray *)bannerViewTitles:(YJBannerView *)bannerView{
        return self.titlesDataSources;
    }
    
    // 代理方法 点击了哪个bannerView 的 第几个元素
    -(void)bannerView:(YJBannerView *)bannerView didSelectItemAtIndex:(NSInteger)index{
        NSString *title = [self.titlesDataSources objectAtIndex:index];
        NSLog(@"当前%@-->%@", bannerView, title);
    }
    

    扩展自定义方法

    // 自定义Cell方法
    - (Class)bannerViewCustomCellClass:(YJBannerView *)bannerView{
        return [HeadLinesCell class];
    }
    
    // 自定义Cell的数据刷新方法
    - (void)bannerView:(YJBannerView *)bannerView customCell:(UICollectionViewCell *)customCell index:(NSInteger)index{
    
        HeadLinesCell *cell = (HeadLinesCell *)customCell;
        [cell cellWithHeadHotLineCellData:@"打折活动开始了~~快来抢购啊"];
    }
    

    Demo地址: GithubDemo

    相关文章

      网友评论

          本文标题:YJBannerView 的使用方法 (iOS 11 适配)

          本文链接:https://www.haomeiwen.com/subject/kdzakxtx.html