CoderZhuXH / HUScrollCycle

一张图片实现的轮播图

Repository from Github https://github.comCoderZhuXH/HUScrollCycleRepository from Github https://github.comCoderZhuXH/HUScrollCycle

HUScrollCycle

一张图片实现的轮播图,支持网络图片

Usage

 let images = ["a.jpg", "b.jpg","c.jpg","d.jpg",].flatMap {
            return UIImage(named: $0)
 }
        
 let cycleView = HUScrollCycleView(frame: CGRectMake(0, 64, self.view.frame.size.width, 200))
 cycleView.delegate = self
 cycleView.images = images
 cycleView.currentPageIndicatorTintColor = UIColor.redColor()
 self.view.addSubview(cycleView)    

加载网络图片:

cycleView.placeholderImage = UIImage(named:"a.jpg")
cycleView.imageURLStringGroup = ["http://1.7feel.cc/yungou/statics/uploads/banner/20160715/85964915563838.jpg",
                                 "http://1.7feel.cc/yungou/statics/uploads/banner/20160715/20274054563730.jpg",
                                 "http://1.7feel.cc/yungou/statics/uploads/banner/20160715/40912708563719.jpg",
                                 "http://1.7feel.cc/yungou/statics/uploads/touimg/20160718/img193.jpg"];

在代理中,你可以得到当前点击图片的下标:

func scrollCycleView(view: HUScrollCycleView, didSelectedItemAtIndex index: Int) {
        print("tap at \(index)")
}

其他一些属性:

属性 说明
timeInterval 轮播时间间隔
pageIndicatorTintColor pageControl颜色
currentPageIndicatorTintColor pageControl当前位置颜色
autoScrollEnable 是否自动轮播
pageControlHidden 是否隐藏pageControl

Install

下载zip包,解压后将HUScrollCycleView文件夹拖入工程中,点击你的工程,在相应的targetBuild Settings中找到Swift Compiler,鼠标双击Objective-C Bridging Header,将HUScrollCycle-Bridging-Header.h拖入到弹出框中,这样Xcode就能找到OC的头文件了。

Other

  • HUScrollCycle中的网络图片下载并没有使用其他第三方库,所以你可以放心使用而不会对你项目产生影响。你只要按照上面的方法正确的导入HUScrollCycle-Bridging-Header.h就可以正常使用了。
  • HUScrollCycle是使用Swift开发的,如果你需要OC版本可以联系我:)

About

一张图片实现的轮播图

License:MIT License


Languages

Language:Objective-C 79.6%Language:Swift 19.5%Language:C 0.9%