欢迎光临
我们一直在努力

[Swift]TGLParallaxCarousel 轮播图

建站超值云服务器,限时71元/月

[Swift]TGLParallaxCarousel 轮播图

项目介绍:

[分享]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 直接下载:

赞(0)
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com 特别注意:本站所有转载文章言论不代表本站观点! 本站所提供的图片等素材,版权归原作者所有,如需使用,请与原作者联系。未经允许不得转载:IDC资讯中心 » [Swift]TGLParallaxCarousel 轮播图
分享到: 更多 (0)