MagicLab Team BannerView Save

Simple Banner View that automatically scrolls. Written in Swift.

Project README

BannerView

Simple Banner View that automatically scrolls.

English localization Arabic localization
Demo Demo

Contents

Requirements

  • iOS 8.0+
  • Xcode 8.0+
  • Swift 3.0+

Installation

CocoaPods

CocoaPods is a dependency manager for Cocoa projects. You can install it with the following command:

$ gem install cocoapods

CocoaPods 1.1.0+ is required to build Reusable 1.0.0+.

To integrate BannerView into your Xcode project using CocoaPods, specify it in your Podfile:

source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '8.0'
use_frameworks!

target '<Your Target Name>' do
    pod 'MLBannerView'
end

Then, run the following command:

$ pod install

Usage

To add BannerView you may set class to view as BannerView in storyboard or create it manually from code.

Setup banner view:

bannerView.setup(
  type: BannerViewScrollType.fromStart,
  timeForOneItem: 1,
  bannerItems: [
    BannerItem(image: UIImage(named: "banner_1")),
    BannerItem(image: UIImage(named: "banner_2")),
    BannerItem(image: UIImage(named: "banner_3"))
  ],
  delegate: self
)

BannerViewDelegate

BannerViewDelegate allows you to be notifed when banner scrolls to next item or when user clicks on item.

/**
 BannerViewDelegate.
 */
@objc public protocol BannerViewDelegate {
    /**
     Notifies when banner view scrolls to the next item.
     */
    @objc optional func bannerView(bannerView: BannerView, didScrollTo: BannerItem, with index: Int)
    
    /**
     Notifies when user selects item.
     */
    @objc optional func bannerView(bannerView: BannerView, didSelectItem: BannerItem, with index: Int)
    
    /**
     Allows to use custom cell.
     */
    @objc optional func bannerView(bannerView: BannerView, 
                                   collectionView: UICollectionView,
                                   cellForItemAt indexPath: IndexPath) -> UICollectionViewCell?
}

There are three possible scroll types

/**
 BannerViewScrollType contains different scroll types.
 */
public enum BannerViewScrollType {
    /**
     BannerView scrolls to the start after the last item.
     */
    case fromStart
    /**
     BannerView scrolls to the end item and then to the first item through all items.
     */
    case reverse
    /**
     BannerView always scrolls forward.
     */
    case alwaysForward
}
.fromStart .reverse .alwaysForward
Demo Demo Demo

BannerPageControl

You may access bannerPageControl through public property

bannerView.pageControl.color = UIColor.black
bannerView.pageControl.currentPageColor = UIColor.green

See more about localization

Localizable

License

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

Open Source Agenda is not affiliated with "MagicLab Team BannerView" Project. README Source: MagicLab-team/BannerView
Stars
52
Open Issues
1
Last Commit
6 years ago
License
MIT

Open Source Agenda Badge

Open Source Agenda Rating