Code Monkey home page Code Monkey logo

sbcyclescrollview's Introduction

SBCycleScrollView

☆☆☆ “功能强大的图片、文字轮播器,支持纯文字、网络图片、本地图片、图片加文字以及各种圆点样式” ☆☆☆

支持pod导入

pod 'SBCycleScrollView','~> 0.0.8'

SBCycleScrollView是一个简单好用的图片轮播器,支持网络图片,本地图片,文字,滑动方向,storyboard以及各种样式.

Github地址,欢迎star😆

使用方式

使用cocoapods导入,pod 'SBCycleScrollView','~>0.0.4',如果发现pod search SBCycleScrollView 搜索出来的不是最新版本,请先执行pod setup指令,获取最新数据源就可以了.

提供三种初始化方式

通过网络图片地址初始化
let cycleScrollView = CycleScrollView.initScrollView(frame: frame, imageNamesGroup: imageUrls, cycleOption: CycleOption())
通过本地图片名称或地址初始化
let cycleScrollView = CycleScrollView.initScrollView(frame: frame, imageNamesGroup: localImages, cycleOptions: CycleOptions())
通过文字数组初始化
let cycleScrollView = CycleScrollView.initScrollView(frame: frame, titleGroup: titles, cycleOption: CycleOption())
推荐方式,通过代理和占位图初始化,常用于图片异步获取的时候
let cycleScrollView = CycleScrollView.initScrollView(frame: frame, delegate: self, placehoder: UIImage.init(named: "place.png"), cycleOptions: CycleOptions())
cycleScrollView.imageURLStringsGroup = imageUrls

通过单独抽取一个struct来管理各种轮播器的各个属性

import UIKit

public enum PageControlStyle {
    case classic,aji,aleppo,chimayo,jalapeno,jaloro,paprika,puya
}
public enum PageControlAliment {
    case center,right
}

public struct CycleOption {
    public  var scrollDirection:UICollectionViewScrollDirection = UICollectionViewScrollDirection.horizontal
    public  var showPageControl: Bool = true//是否显示pageControl,默认显示
    public  var isOnlyDisplayText: Bool = false//只显示文字,默认false
    public  var imageViewMode: UIViewContentMode = UIViewContentMode.scaleToFill //图片填充样式,默认fill
    public  var scrollTimeInterval: TimeInterval = 2.0//滑动间隔时间
    public  var titleLabelBackgroundColor: UIColor = .init(red: 0, green: 0, blue: 0, alpha: 0.2)//label背景颜色
    public  var textColor: UIColor = .white//文字颜色
    public  var textFont: UIFont = UIFont.systemFont(ofSize: 14)//文字字体大小
    public  var titleLabelHeight: CGFloat = 30//label高度,默认30
    public  var textAlignment: NSTextAlignment = NSTextAlignment.left//文字默认居左
    public  var numberOfline = 1 // 文字行数,默认一行
    public  var radius: CGFloat = 5//pageControl圆点半径
    public  var pageAliment: PageControlAliment = PageControlAliment.center//pageControl位置,默认居中
    public  var bottomOffset: CGFloat = 0//pageControl距离底部距离
    public  var rightOffset: CGFloat = 0//pageControl距离右侧距离
    public  var padding: CGFloat = 7 //pagecontol间距
    public  var pageStyle: PageControlStyle = PageControlStyle.classic//pageControl样式,默认系统样式
    public  var currentPageDotColor: UIColor = .white//当前pageControl圆点的颜色
    public  var pageDotColor: UIColor = .gray//其他pageControl圆点的颜色
}

点击图片代理

代理名称SBCycleScrollViewDelegate,代理方法

func didSelectedCycleScrollView(_ cycleScrollView: SBCycleScrollView, _ Index: NSInteger) {
        print("点击了第\(Index)张图片")
    }

####修改配置属性,达到你想要的效果

\\先配置再初始化
        var option = CycleOption()
        option.currentPageDotColor = .blue
        option.radius = 10
        option.pageStyle = PageControlStyle.jalapeno
        let cycleScrollView = CycleScrollView.initScrollView(frame: view.frame, imageURLsGroup: imageUrls, cycleOption: option)
\\初始化后再修改配置
        let cycleScrollView = CycleScrollView.initScrollView(frame: view.frame, imageURLsGroup: imageUrls, cycleOption: CycleOption())
        var option = CycleOption()
        option.currentPageDotColor = .blue
        option.radius = 10
        option.pageStyle = PageControlStyle.jalapeno
        cycleScrollView.option = option

####点击图片代理 代理名称SBCycleScrollViewDelegate,代理方法

 func didSelectedCycleScrollView(_ cycleScrollView: CycleScrollView, _ Index: NSInteger) {
        print("点击了第\(Index)张图片")
    }

效果图展示:

结语

如果这个组件能够帮助到你我会非常开心,当然我也希望有大佬能够帮我指出我代码中的问题,毕竟我学swift时间不久,代码还有很多不足的地方,如果可以,非常感谢.

希望大家能给个star,你们的鼓励是我前进的动力.

Github地址,欢迎star😆

sbcyclescrollview's People

Contributors

xumaohuai avatar

Stargazers

Mr.Plus avatar  avatar  avatar FanXiaobin avatar jack lin avatar  avatar  avatar  avatar  avatar MarsGao avatar Michael avatar  avatar xxlgm avatar  avatar SKCodeing avatar Been avatar  avatar  avatar  avatar  avatar  avatar  avatar PETER SHI avatar  avatar 伊欧 avatar 挡不住的君文 avatar HONGQUAN avatar Wely avatar  avatar  avatar  avatar  avatar Hz avatar  avatar  avatar  avatar  avatar 安爷 avatar  avatar Flashes avatar  avatar  avatar miles zarathustra avatar 爱编码 avatar DongHee Kang avatar MohsinAli avatar GHome avatar  avatar Hand of the King avatar Beryter avatar 随心而动的猿 avatar Single avatar  avatar  avatar  avatar  avatar lxp avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar kakj avatar Argent sky avatar  avatar  avatar kevin9041 avatar  avatar 梅子酒 avatar  avatar  avatar  avatar hua.jiao avatar  avatar  avatar  avatar  avatar  avatar  avatar fangzongzhou avatar  avatar  avatar  avatar  avatar hakon avatar  avatar  avatar Hendy Rodrigues Ferreira da Silva avatar  avatar  avatar  avatar Sun avatar  avatar  avatar  avatar  avatar  avatar monday avatar

Watchers

MohsinAli avatar gsp avatar  avatar

sbcyclescrollview's Issues

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.