Swift轮播控件快速入门——FSPagerView

今天介绍一个IOS的轮播控件FSPagerView。

FSPagerView是一个优雅的轮播控件,它可以十分轻松有效地制作轮播视图、产品展示、欢迎/指南页面。

先上地址——Swift:  https://github.com/WenchaoD/FSPagerView

                    OC:  https://github.com/WenchaoD/FSPagerView/blob/master/README-OBJECTIVE-C.md

Cocoapods集成方式——  pod 'FSPagerView'

下载完成后导入FSPagerView:

import FSPagerView
初次导入时XCode会报错找不到项目,只要Build一下即可消除错误

使用方法——  1.懒加载获取FSPagerView和FSPageControl的实例,在闭包中设置各个属性

                        FSPagerView是轮播视图类,FSPageControl是下标指示器类

                     lazy var viewPager: FSPagerView = {
                        let viewPager = FSPagerView()
                        viewPager.frame = frame1
            
源码iOS-ViewPagerIndicator,Paging indicator widgets,swift版的分页指示器,可以配合UIScrollView使用完成分页控制,Paging indicator widgets,swift版的分页指示器,可以配合UIScrollView使用完成分页控制 //样式设置 viewPagerIndicator.setTitleColorForState(UIColor.blackColor(), state: UIControlState.Selected)//选中文字的颜色 viewPagerIndicator.setTitleColorForState(UIColor.blackColor(), state: UIControlState.Normal)//正常文字颜色 viewPagerIndicator.tintColor = UIColor.brownColor()//指示器和基线的颜色 viewPagerIndicator.showBottomLine = false//基线是否显示 viewPagerIndicator.autoAdjustSelectionIndicatorWidth = true//指示器宽度是按照文字内容大小还是按照count数量平分屏幕 viewPagerIndicator.indicatorDirection = .Top//指示器位置 viewPagerIndicator.indicatorHeight = viewPagerIndicator.bounds.height//指示器高度 //点击viewPagerIndicator可以控制scrollView //滑动scrollView可以改变viewPagerIndicator //点击顶部选中后回调 func indicatorChange(indicatorIndex: Int){ scrollView.scrollRectToVisible(CGRectMake(self.view.bounds.width * CGFloat(indicatorIndex), 0, self.view.bounds.width, scrollViewHeight), animated: true) } //滑动scrollview回调 func scrollViewDidEndDecelerating(scrollView: UIScrollView) { var xOffset: CGFloat = scrollView.contentOffset.x var x: Float = Float(xOffset) var width:Float = Float(self.view.bounds.width) let index = Int((x + (width * 0.5)) / width) viewPagerIndicator.setSelectedIndex(index)//改变顶部选中 }
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值