项目介绍:
[分享]TGLParallaxCarousel
A lightweight 3D Linear Carousel with parallax effect(一个轻量级的3D旋转轮播图)
使用说明:
1) Place one UIView object in your VC in the Storyboard and set it as subclass of TGLParallaxCarousel
2) Create an IBOutlet in your VC.swift file, connect it a connect delegate and datasource.
[Objective-C] 查看源文件 复制代码
@IBOutlet weak var carouselView: TGLParallaxCarousel! override func viewDidLoad() { super.viewDidLoad() carouselView.delegate = self carouselView.datasource = self carouselView.itemMargin = 10 } // MARK: TGLParallaxCarousel datasource func numberOfItemsInCarousel(carousel: TGLParallaxCarousel) ->Int { return 5 } func viewForItemAtIndex(index: Int, carousel: TGLParallaxCarousel) -> TGLParallaxCarouselItem { return CustomView(frame: CGRectMake(0, 0, 300, 150), number: "\(index + 1)") }
3) Set the datasource. Each item must be subclass of TGLParallaxCarouselItem
[Objective-C] 查看源文件 复制代码
func numberOfItemsInCarousel(carousel: TGLParallaxCarousel) ->Int { return 5 } func viewForItemAtIndex(index: Int, carousel: TGLParallaxCarousel) -> TGLParallaxCarouselItem { return CustomView(frame: CGRectMake(0, 0, 300, 150), number: "\(index + 1)") }
4) Listen to delegate
[Objective-C] 查看源文件 复制代码
func didTapOnItemAtIndex(index: Int, carousel: TGLParallaxCarousel) { print("Tap on item at index \(index)") } func didMovetoPageAtIndex(index: Int) { print("Did move to index \(index)") }
5) Enjoy!
DEMO 直接下载: