iOS开发-图片轮播器

开篇

  最近公司项目还没有开始,就自己在网上找了一些资料,封装了一个图片轮播器,打包传到了github上,也支持了cocoapods.在这里和家分享一下.喜欢的朋友可以使用一下,有什么bug可以直接联系我.

一 简介

LN_PictureCarousel 是一个可以实现本地和网络图片的轮播器

二 使用方法

1.注意事项:

1.1需要引入第三方框架

pod 'SDWebImage'

1.2支持cocoapods 导入

pod 'LN_PictureCarousel' , '~> 1.0.0' 

2.具体使用如下:

2.1创建数组和frame


    NSMutableArray *photosMArr = [[NSMutableArray alloc] init];
    for (int i = 0; i < 5; i++) {
        
        NSString *str = [NSString stringWithFormat:@"%d.jpg", i];
        UIImage *image = [UIImage imageNamed:str];
                          
        [photosMArr addObject:str];
    }
    
    CGRect frame = CGRectMake(0, 0, self.view.frame.size.width, 200.f);

2.2本地图片

        //类方法
   [LN_PictureCarousel pictureWithParent:self.view frame:frame imagesArray:photosMArr timeInterval:1.5 action:^(LN_PictureCarousel *pictureCarousel, NSInteger selectIndex) {
    
        NSLog(@"点击了第%ld张图片",selectIndex);
   }];
    
        //对象方法
    [[LN_PictureCarousel alloc] initWithParent:self.view frame:frame imagesArray:photosMArr timeInterval:1.5 action:^(LN_PictureCarousel *pictureCarousel, NSInteger selectIndex) {
        
         NSLog(@"点击了第%ld张图片",selectIndex);
    }];

2.3本地图片,数组为图片名字数组

        //类方法
    [LN_PictureCarousel pictureWithParent:self.view frame:frame imagesStringArray:photosMArr timeInterval:1.2 action:^(LN_PictureCarousel *pictureCarousel, NSInteger selectIndex) {
         NSLog(@"点击了第%ld张图片",selectIndex);
    }];
    
        //对象方法
    [[LN_PictureCarousel alloc] initWithParent:self.view frame:frame imagesStringArray:photosMArr timeInterval:1.2f action:^(LN_PictureCarousel *pictureCarousel, NSInteger selectIndex) {
        
        NSLog(@"点击了第%ld张图片",selectIndex);
    }];

2.4网络图片

    NSArray *photonStrs = @[
                            @"https://raw.githubusercontent.com/LionNeo/LN_Photos/master/%E6%B5%8B%E8%AF%95%E5%9B%BE%E7%89%87/0.jpg",
                            @"https://raw.githubusercontent.com/LionNeo/LN_Photos/master/%E6%B5%8B%E8%AF%95%E5%9B%BE%E7%89%87/1.jpg",
                            @"https://raw.githubusercontent.com/LionNeo/LN_Photos/master/%E6%B5%8B%E8%AF%95%E5%9B%BE%E7%89%87/2.jpg",
                            @"https://raw.githubusercontent.com/LionNeo/LN_Photos/master/%E6%B5%8B%E8%AF%95%E5%9B%BE%E7%89%87/3.jpg",
                            @"https://raw.githubusercontent.com/LionNeo/LN_Photos/master/%E6%B5%8B%E8%AF%95%E5%9B%BE%E7%89%87/4.jpg"
                            ];
    
    [LN_PictureCarousel pictureWithParent:self.view frame:frame imagesUrlStringArray:photonStrs timeInterval:1.2f action:^(LN_PictureCarousel *pictureCarousel, NSInteger selectIndex) {
        NSLog(@"点击了第%ld张图片",selectIndex);
        
    }];
    
    [[LN_PictureCarousel alloc] initWithParent:self.view frame:frame imagesUrlStringArray:photonStrs timeInterval:1.2 action:^(LN_PictureCarousel *pictureCarousel, NSInteger selectIndex) {
        
        NSLog(@"点击了第%ld张图片",selectIndex);
    }];

三 Github --> 图片轮播器地址

尾记 --> 更多关于ios开发的心得记录,会在以后慢慢展开,谢谢关注.

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • Swift版本点击这里欢迎加入QQ群交流: 594119878最新更新日期:18-09-17 About A cu...
    ylgwhyh阅读 25,663评论 7 249
  • 之默物语 亲爱的你,当坚持已无意义,请选择勇敢放弃。 往事莫沉吟,身间时序好,且登临。这才是我们应该持有的态度。 ...
    范雨辰阅读 1,784评论 0 6
  • 零星残云余霞 枯草断枝荒原 街灯高楼宝塔 夜幕袭来 鸡鸣犬吠蛙呱 ——柳子 2013.09.13 作于滇东
    五柳散人阅读 201评论 0 3
  • 记得委屈,记得恨,记得伤痛,记得离别,过去如白驹过隙,不过一眨眼而已,留下遗憾,剩下悔恨,又铭刻过几分爱在心头,...
    风过花陌落阅读 233评论 0 1
  • 整个国庆都迷迷糊糊不知道在干嘛,商演也好几场了,钱都不知道怎么花出去了,昨天晚上的商演感慨挺多的,成人的世界其实也...
    大扣二阅读 186评论 0 0