Git Product home page Git Product logo

llcyclescrollview's Introduction

iOS图片轮播 LLCycleScrollView

License Platform

实在抱歉

该仓库目前停更已久,代码老旧,作为iOS开发人员由于进入的某二线,说是新一线的城市,岗位的需求急剧下降,目前被发配开发区块链、开发小程序、开发大前端、开发Java.....咳咳,总之很苦逼了。未来有时间我争取改造或者使用SwiftUI来进行开发,届时会第一时间提交,感谢朋友一路陪伴,学习使用,代码质量不足之处居多,一起加油。

Issues

如果使用过程中,有什么问题欢迎issues。

Swift

Swift3 请使用1.3.x版本 Swift4 请使用1.4.x版本 Swift4.2 请使用1.5.1+版本 Swift5 请使用1.6.0版本

Support

  • 支持纯图片
  • 支持文本图片结合
  • 支持横向滚动
  • 支持纵向滚动
  • 支持手势滑动
  • 支持点击回调
  • 支持图片数据的延时加载
  • 支持没有数据,占位图占位(仅设置CoverImage(有默认图)即可)
  • 支持本地图片显示及与网络图的混合显示
  • 支持系统UIPageControl位置设置
  • 支持StoryBoard
  • 支持纯文本
  • 支持CustomPageControl位置设置
  • 支持协议
  • 支持左右箭头点击风格

Update

版本信息 更新描述
1.6.0 * 依赖最新的库版本,Target iOS 10
1.5.4 * 修复异步数据崩溃问题
1.5.3 * 修复依赖库版本问题
1.5.2 * 修复PageControl重置问题
* 修复Xib初始化不自动轮播
1.5.1 * 迁移Swift 4.2
1.5.0 * 支持左右方向箭头点击风格
* 优化部分代码结构
* 优化定时器引用问题
1.4.9 * 支持图片发生切换回调协议
* 修复图片更新为一张图时滚动行为
1.4.8 * fixed #37 'delegate' is inaccessible due to 'internal' protection level
1.4.7 * 修复反向滑动问题
* 修改纯文本下高度设置问题;
1.4.6 * 新增协议回调方法
* 新增开启/关闭URL特殊字符处理
* 优化数量为0的计算控制
1.4.5 * 新增协议回调方法
* 新增开启/关闭URL特殊字符处理
* 优化数量为0的计算控制
1.4.4 * 修复:数据为空的时候的不能设置图片的显示mode
* 自定义PageControl图标
* 修复单张图滚动问题
* 修复infiniteLoop为false后的还可以滚动的逻辑问题
1.4.3 * 优化没有数据时候,标题背景的显示问题
1.4.2 * 增加容错率->titles不使用默认,赋值nil出错问题
1.4.1 * UPDATE
1.4.0 * Swift4
1.3.6 * 区分使用
1.3.5 * 指定支持Swift4的依赖库版本
1.3.4 * 增加自定义PageControl的位置控制pageControlPosition
1.3.3 * 修复titles数据异步加载问题
1.3.2 * 由于IBDesignable问题,临时取消,后续会检查更新
1.3.1 * 修复图placeHolder显示问题
1.3.0 * 修复StoryBoard在部分设备显示问题
1.2.9 * 增加支持文本Leading约束属性titleLeading
* PageControl的Bottom约束属性pageControlBottom
1.2.8 * 支持纯文本部分属性修改,没有开放Label
1.2.7 * 支持纯文本
1.2.6 * 修改自定义PageControl反向滚动时候,pageControl的方向控制问题
1.2.5 * 修复自定义PageControl快速滚动问题,修复系统UIPageControl位置left&right对换设置问题
1.2.4 * 支持系统UIPageControl位置设置,其属性pageControlPosition
* 公开pageControl及customPageControl两个控件,方便控制及自定义
1.2.3 * 支持本地图片显示及与网络图的混合显示
* 增加图片contentMode的控制
1.2.2 * 标题显示两行文字
1.2.1 * 支持不同类型的PageControl
* 支持修改PageControl颜色,当前显示颜色等(文件注释)
1.1.1 * 支持Storyboard

CocoaPods

  • 支持CocoaPods
pod 'LLCycleScrollView' 

Usage

let bannerDemo = LLCycleScrollView.llCycleScrollViewWithFrame(CGRect.init(x: 0, y: bannerDemo.ll_y + 205, width: w, height: 200))
// 是否自动滚动
bannerDemo.autoScroll = true

// 是否无限循环,此属性修改了就不存在轮播的意义了 😄
bannerDemo.infiniteLoop = true

// 滚动间隔时间(默认为2秒)
bannerDemo.autoScrollTimeInterval = 3.0

// 等待数据状态显示的占位图
bannerDemo.placeHolderImage = #UIImage

// 如果没有数据的时候,使用的封面图
bannerDemo.coverImage = #UIImage

// 设置图片显示方式=UIImageView的ContentMode
bannerDemo.imageViewContentMode = .scaleToFill

// 设置滚动方向( vertical || horizontal )
bannerDemo.scrollDirection = .vertical

// 设置当前PageControl的样式 (.none, .system, .fill, .pill, .snake)
bannerDemo.customPageControlStyle = .snake

// 非.system的状态下,设置PageControl的tintColor
bannerDemo.customPageControlInActiveTintColor = UIColor.red

// 设置.system系统的UIPageControl当前显示的颜色
bannerDemo.pageControlCurrentPageColor = UIColor.white

// 非.system的状态下,设置PageControl的间距(默认为8.0)
bannerDemo.customPageControlIndicatorPadding = 8.0

// 设置PageControl的位置 (.left, .right 默认为.center)
bannerDemo.pageControlPosition = .center

// 背景色
bannerDemo.collectionViewBackgroundColor

// 添加到view
self.addSubview(bannerDemo1)

// 模拟网络图片获取
DispatchQueue.main.asyncAfter(deadline: DispatchTime.now() + .seconds(2)) {
  bannerDemo.imagePaths = imagesURLStrings
}

Example

示例代码见ViewController.swift

Future

  • 优化代码
  • 未来将计划创建新版本,从而使用上更简单明了

Author

LvJianfeng, [email protected]

llcyclescrollview's People

Contributors

crazypoo avatar gewill avatar hansoncoder avatar imazy avatar lvjianfeng avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

llcyclescrollview's Issues

一张图片时行为不一致

数量从多张更新为一张时,一张图会滚动轮播,与从一开始设置一张图时不滚动行为不一致

pageControl 分页的小点

当用手不断滑动时,下面的分页小圆点没有跟着图片对应 总体体验很好,希望这个库越来越好

自定义pageControl的位置

我希望能自定义pageControl的位置,最好能设置居左居中居右,或者把pageControl这个属性公开出来,我可以在layout里自己控制位置,希望能尽快支持,眼下我只能自己再加一个pageControl了

10

下载下来。一运行就报错。。这个是不是需要配置神马?

控制上一页下一页的属性

现在有个需求要在轮播左右加上箭头,但是点击的时候需要控制当前显示的page,找了好久没找到这样的属性,希望下个版本提供一下或者弄个样式选择枚举直接加上左右箭头

error in storyboard

My LLCycleScrollView install with Cocoapods. In storyboard, Xcode have a error:

file:///Users/zhangrunliang/Work/TestLLCycleScrollView/TestLLCycleScrollView/Base.lproj/Main.storyboard: error: IB Designables: Failed to render and update auto layout status for ViewController (BYZ-38-t0r): dlopen(LLCycleScrollView.framework, 1): Library not loaded: @rpath/Kingfisher.framework/Kingfisher
Referenced from: LLCycleScrollView.framework
Reason: image not found

file:///Users/zhangrunliang/Work/TestLLCycleScrollView/TestLLCycleScrollView/Base.lproj/Main.storyboard: error: IB Designables: Failed to update auto layout status: dlopen(LLCycleScrollView.framework, 1): Library not loaded: @rpath/Kingfisher.framework/Kingfisher
Referenced from: LLCycleScrollView.framework
Reason: image not found

Can you help me? Thank you very much.

没有1.4x版本

pod 什么还没有没有见1.4x 版本。我刚好用swift4.0写

是我的使用方式不对,还是有内存泄漏

 let banner = LLCycleScrollView.llCycleScrollViewWithFrame(CGRect.zero)
            self.view.addSubview(banner)
            banner.snp.makeConstraints({ (make) in
                make.left.equalToSuperview().offset(AdaptedWidth(x: 15))
                make.right.equalToSuperview().offset(-AdaptedWidth(x: 15))
                make.top.equalTo(self.leftItem.snp.bottom).offset(AdaptedWidth(x: 14))
                make.height.equalTo(AdaptedWidth(x: 55))
            })
            banner.autoScrollTimeInterval = 1
            banner.backgroundColor = UIColor.red
            banner.scrollDirection = .vertical
            banner.customPageControlStyle = .snake
            banner.imagePaths = ["公告","活动-1","教程"]

2017-11-30 10 58 04

影响Interface Builder不呈现自定义@IBDesignable视图

file://......./HomeStoryboard.storyboard: error: IB Designables: Failed to render and update auto layout status for ELHomeViewController : dlopen(LLCycleScrollView.framework, 1): Library not loaded: @rpath/Kingfisher.framework/Kingfisher
Referenced from: LLCycleScrollView.framework
Reason: image not found

代码在模拟器上编译并正确运行。此问题仅影响Interface Builder不呈现自定义@IBDesignable视图。

Remainder of division by zero

你好,在这个方法中,当imagePaths为0的时候需要先判断再计算,不然就崩溃了
func pageControlIndexWithCurrentCellIndex(index: NSInteger) -> (Int) {
return Int(index % imagePaths.count)
}

Failed to update auto layout status

Hi,

Issues still remained.My Xcode is 8.3.3
It's same to #8 #9
file:///xcode/%E6%88%91%E5%9C%A8%E9%87%8D%E5%86%99/xxxx/Main.storyboard: error: IB Designables: Failed to update auto layout status: dlopen(LLCycleScrollView.framework, 1): Library not loaded: .framework/Kingfisher
Referenced from: LLCycleScrollView.framework
Reason: image not found

I pod update the podfile. Then restart my Xcode. Problem still lay there.

优化建议

老铁可以整理一下代码风格吗? 加上 swiftlint gitignore???
fork 了一下,改不动了嘤嘤嘤

improve the url supporting

 let escapedString = imagePath.addingPercentEncoding(withAllowedCharacters: .urlQueryAllowed)
 cell.imageView.kf.setImage(with: URL(string: escapedString!), placeholder: placeHolderImage)

当没有设置imagePaths的时候滑动会数组越界

SKPhotoBrowser.swift

public convenience init(photos: [SKPhotoProtocol], initialPageIndex: Int) {
self.init(nibName: nil, bundle: nil)
*********************
// photos.count = 0
// currentPageIndex = -1
self.currentPageIndex = min(initialPageIndex, photos.count - 1)
*********************
// 崩溃
animator.senderViewForAnimation = photos[currentPageIndex] as? UIView
}

当没有设置imagePaths的时候滑动会出现

snake style 下设置pageControl的FillPageControlIndicatorRadius有问题 选中点不变化

   // Demo--延时加载数据之滚动方向控制
    let bannerDemo1 = LLCycleScrollView.llCycleScrollViewWithFrame(CGRect.init(x: 0, y: bannerDemo.ll_y + 205, width: w, height: 200))
    // 垂直滚动
    bannerDemo1.FillPageControlIndicatorRadius = 2;
    bannerDemo1.customPageControlIndicatorPadding = 10;
    bannerDemo1.customPageControlTintColor = UIColor.red;
    bannerDemo1.customPageControlInActiveTintColor = UIColor.white;
    bannerDemo1.customPageControlStyle = .snake

    scrollView.addSubview(bannerDemo1)

    DispatchQueue.main.asyncAfter(deadline: DispatchTime.now() + .seconds(2)) {
        bannerDemo1.imagePaths = imagesURLStrings
    }

图片出现错位,警告信息如下

2018-03-22 18:39:26.664765+0800 HaoDLSwift[2494:932542] The behavior of the UICollectionViewFlowLayout is not defined because:
2018-03-22 18:39:26.664863+0800 HaoDLSwift[2494:932542] the item height must be less than the height of the UICollectionView minus the section insets top and bottom values, minus the content insets top and bottom values.
2018-03-22 18:39:26.665880+0800 HaoDLSwift[2494:932542] The relevant UICollectionViewFlowLayout instance is <UICollectionViewFlowLayout: 0x10181eaa0>, and it is attached to <UICollectionView: 0x102090000; frame = (0 0; 375 200); clipsToBounds = YES; gestureRecognizers = <NSArray: 0x17004d1d0>; layer = <CALayer: 0x170226540>; contentOffset: {0, -20}; contentSize: {0, 0}> collection view layout: <UICollectionViewFlowLayout: 0x10181eaa0>.
2018-03-22 18:39:26.665949+0800 HaoDLSwift[2494:932542] Make a symbolic breakpoint at UICollectionViewFlowLayoutBreakForInvalidSizes to catch this in the debugger.
2018-03-22 18:39:28.865031+0800 HaoDLSwift[2494:932542] The behavior of the UICollectionViewFlowLayout is not defined because:
2018-03-22 18:39:28.865207+0800 HaoDLSwift[2494:932542] the item height must be less than the height of the UICollectionView minus the section insets top and bottom values, minus the content insets top and bottom values.
2018-03-22 18:39:28.865972+0800 HaoDLSwift[2494:932542] The relevant UICollectionViewFlowLayout instance is <UICollectionViewFlowLayout: 0x10181eaa0>, and it is attached to <UICollectionView: 0x102090000; frame = (0 0; 375 200); clipsToBounds = YES; gestureRecognizers = <NSArray: 0x17004d1d0>; layer = <CALayer: 0x170226540>; contentOffset: {0, -20}; contentSize: {375, 131}> collection view layout: <UICollectionViewFlowLayout: 0x10181eaa0>.
2018-03-22 18:39:28.866077+0800 HaoDLSwift[2494:932542] Make a symbolic breakpoint at UICollectionViewFlowLayoutBreakForInvalidSizes to catch this in the debugger.

wechatimg1 2

后台一直会输出这个警告:The relevant UICollectionViewFlowLayout instance is

2017-10-09 14:07:57.204040+0800[10448:1222328] The relevant UICollectionViewFlowLayout instance is <UICollectionViewFlowLayout: 0x7fec1d71c860>, and it is attached to <UICollectionView: 0x7fec1f09ac00; frame = (0 0; 414 165.667); clipsToBounds = YES; gestureRecognizers = <NSArray: 0x60400024bdf0>; layer = <CALayer: 0x60400023aba0>; contentOffset: {414, 0}; contentSize: {207000, 165.66666666666663}; adjustedContentInset: {1.4210854715202004e-14, 0, 0, 0}> collection view layout: <UICollectionViewFlowLayout: 0x7fec1d71c860>.
2017-10-09 14:07:57.204131+0800[10448:1222328] Make a symbolic breakpoint at UICollectionViewFlowLayoutBreakForInvalidSizes to catch this in the debugger.
2017-10-09 14:08:03.358997+0800[10448:1222328] The behavior of the UICollectionViewFlowLayout is not defined because:
2017-10-09 14:08:03.359166+0800[10448:1222328] the item height must be less than the height of the UICollectionView minus the section insets top and bottom values, minus the content insets top and bottom values.

通过下拉刷新 重新赋值 imagePaths 会导致 LLCycleScrollView customPageControl 显示异常

private func initViews() {
// LLCycleScrollView 初始化代码
csvMain.autoScroll = true
csvMain.autoScrollTimeInterval = 5.0
csvMain.imageViewContentMode = .scaleToFill
csvMain.infiniteLoop = true
csvMain.placeHolderImage = UIImage(named: "place_holder_image")
csvMain.coverImage = UIImage(named: "place_holder_image")
csvMain.backgroundColor = UIColor(hexString: ColorRes.transparent)
csvMain.delegate = self

    csvMain.customPageControlStyle = .fill
    csvMain.pageControlBottom = 14.0
    csvMain.FillPageControlIndicatorRadius = 3.6
    csvMain.pageControlLeadingOrTrialingContact = 3
}

// 下拉刷新 调用该方法,重置 LLCycleScrollView imagePaths
private func reloadData() {
var imagePaths: [String] = []
for i in 0 ..< bannerData.count {
let baseUrl = bannerData[i]["baseUrl"].stringValue
let imageUrl = bannerData[i]["imageUrl"].stringValue

        imagePaths.append(baseUrl + imageUrl)
    }
    
    csvMain.imagePaths = imagePaths

// 重置 LLCycleScrollView imagePaths, 后 PageControl 显示错乱,但在一次autoScroll后 恢复正常。
}

请修复该问题。

更新到Swift4了

你没适配Swift4啊,你引用的Kingfisher不能自动更新到Swift4,能速度更新一下吗,今天刚更新的

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.