Simple Banner View that automatically scrolls.
English localization | Arabic localization |
---|---|
- iOS 8.0+
- Xcode 8.0+
- Swift 3.0+
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
To add BannerView you may set class to view as BannerView in storyboard or create it manually from code.
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 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?
}
/**
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 |
---|---|---|
You may access bannerPageControl through public property
bannerView.pageControl.color = UIColor.black
bannerView.pageControl.currentPageColor = UIColor.green
BannerView is released under the MIT license. See LICENSE for details.