Giter Club home page Giter Club logo

zcycleview's Introduction

ZCycleView

A picture/text infinite-scroll library with UICollectionView, It can be very easy to help you make the banner you want

使用UICollectionView实现常见图片/文字无限轮播,支持自定义pageControl,自定义文字样式,以及轮播样式

image

How To

Basic usage

pretty easy to use,Basic usage like this

let cycleView = ZCycleView(frame: frame)
cycleView.placeholderImage = UIImage(named: "placeholder")
cycleView.setUrlsGroup(["http://...", "http://...", "http://..."], titlesGroup: ["...", "..."])
view.addSubview(cycleView)

Set image or image url or text

you can also set the desc titlesGroup or attributedTitlesGroup, pick one of two, attributedTitlesGroup first

/// image
func setImagesGroup(_ imagesGroup: Array<UIImage?>, titlesGroup: [String?]? = nil, attributedTitlesGroup: [NSAttributedString?]? = nil)
/// image url
func setUrlsGroup(_ urlsGroup: Array<String>, titlesGroup: [String?]? = nil, attributedTitlesGroup: [NSAttributedString?]? = nil)
/// text only
func setTitlesGroup(_ titlesGroup: Array<String?>?, attributedTitlesGroup: [NSAttributedString?]? = nil)

If you want the effect in the picture below, use the following method

Special reminder, be sure to set the size, otherwise the picture does not display

func setTitleImagesGroup(_ titleImagesGroup: [UIImage?], sizeGroup:[CGSize?])
func setTitleImageUrlsGroup(_ titleImageUrlsGroup: [String?], sizeGroup:[CGSize?])

About item settings

/// The size of the item, the default cycleView size
var itemSize: CGSize?
/// The scale of the center item
var itemZoomScale: CGFloat = 1
/// The space of items
var itemSpacing: CGFloat = 0
/// corner radius
var itemCornerRadius: CGFloat = 0
/// item borderColor
var itemBorderColor: UIColor = UIColor.clear
/// item borderWidth
var itemBorderWidth: CGFloat = 0

E.g, Effect as shown below

cycleView.itemSize = CGSize(width: 240, height: 90)
cycleView.itemZoomScale = 1.2

About desc settings

/// The height of the desc containerView, if you set the left image, is also included
var titleViewHeight: CGFloat = 25
/// titleAlignment
public var titleAlignment: NSTextAlignment = .left
/// desc font
public var titleFont: UIFont = UIFont.systemFont(ofSize: 13)
/// The backgroundColor of the desc containerView
public var titleBackgroundColor: UIColor = UIColor(red: 0, green: 0, blue: 0, alpha: 0.5)
/// titleColor
public var titleColor: UIColor = UIColor.white
/// The number of lines of text displayed
public var titleNumberOfLines = 1
/// The breakMode of lines of text displayed
public var titleLineBreakMode: NSLineBreakMode = .byWordWrapping

About pageControl settings

/// Whether to hide pageControl, the default `false`
var pageControlIsHidden = false
/// Dot color, the default `gray`
var pageControlIndictirColor = UIColor.gray
/// Current dot color, the default `white`
var pageControlCurrentIndictirColor = UIColor.white
/// The current dot image
var pageControlCurrentIndictorImage: UIImage?
/// The dot image
var pageControlIndictorImage: UIImage?
/// The height of pageControl, default `25`
var pageControlHeight: CGFloat = 25
/// PageControl's backgroundColor
var pageControlBackgroundColor = UIColor.clear
/// The size of all dots
var pageControlItemSize = CGSize(width: 8, height: 8)
/// The size of current dot
var pageControlCurrentItemSize: CGSize?
/// The space of dot
var pageControlSpacing: CGFloat = 8
/// pageControl Alignment, left/right/center , default `center`
var pageControlAlignment: ZCyclePageControlAlignment = .center
/// the radius of dot
var pageControlItemRadius: CGFloat?
/// the radius of current dot
var pageControlCurrentItemRadius: CGFloat?

didSelectedItem, didScrollToIndex

Click and scroll events are in the form of closures or delegate

/// scrollToIndex
func cycleViewDidScrollToIndex(_ index: Int)

/// selectedIndex
func cycleViewDidSelectedIndex(_ index: Int)
/// click
var didSelectedItem: ((Int)->())?
/// scroll
var didScrollToIndex: ((Int)->())?

Other prototype

/// isAutomatic
var isAutomatic: Bool = true
/// isInfinite
var isInfinite: Bool = true
/// scroll timeInterval
var timeInterval: Int = 2
/// scrollDirection
var scrollDirection: UICollectionViewScrollDirection = .horizontal
/// placeholderImage
var placeholderImage: UIImage? = nil

dependency

Kingfisher

Contact

LICENSE

ZCycleView is released under the MIT license. See LICENSE for details.

zcycleview's People

Contributors

imazy avatar leeyz avatar moshiwu avatar mqzhot avatar

Watchers

 avatar

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.