All Projects → nrlnishan → Viewpager Swift

nrlnishan / Viewpager Swift

Licence: mit
Simple View Pager library for swift using UIPageViewController and Scroll View

Programming Languages

swift
15916 projects

Projects that are alternatives of or similar to Viewpager Swift

Androidanimationexercise
Android 动画各种实现,包括帧动画、补间动画和属性动画的总结分享
Stars: ✭ 1,254 (+822.06%)
Mutual labels:  viewpager
Loopviewpagerlayout
☺无限轮播ViewPagerLayout 广告栏 banner 多种滑动的样式 使用API简单明了
Stars: ✭ 100 (-26.47%)
Mutual labels:  viewpager
Xbanner
🔥【图片轮播】支持图片无限轮播,支持AndroidX、自定义指示点、显示提示文字、切换动画、自定义布局,一屏显示多个等功能
Stars: ✭ 1,734 (+1175%)
Mutual labels:  viewpager
Bannerlayout
Support unlimited picture rotation BannerLayout, the minimum implementation of the code banner
Stars: ✭ 92 (-32.35%)
Mutual labels:  viewpager
Autonotifyviewpager
Automatically notifies viewpager's adapter, when content is changed.
Stars: ✭ 96 (-29.41%)
Mutual labels:  viewpager
Whatsappviewpager
Swipeable tabs like WhatsApp in Android
Stars: ✭ 115 (-15.44%)
Mutual labels:  viewpager
Magicindicator
A powerful, customizable and extensible ViewPager indicator framework. As the best alternative of ViewPagerIndicator, TabLayout and PagerSlidingTabStrip —— 强大、可定制、易扩展的 ViewPager 指示器框架。是ViewPagerIndicator、TabLayout、PagerSlidingTabStrip的最佳替代品。支持角标,更支持在非ViewPager场景下使用(使用hide()、show()切换Fragment或使用setVisibility切换FrameLayout里的View等),http://www.jianshu…
Stars: ✭ 8,969 (+6494.85%)
Mutual labels:  viewpager
Widgetlayout
自定义ViewGroup的集合(有 kotlin 实现分支):提高编写效率和 UI 绘制性能,少嵌套,易用易扩展。
Stars: ✭ 130 (-4.41%)
Mutual labels:  viewpager
Rvpindicator
ViewPager指示器 实现联动,自身滚动,支持类型 : 下滑线,三角形,全背景,图片
Stars: ✭ 99 (-27.21%)
Mutual labels:  viewpager
Zjywidget
🎨 一组实用炫酷自定义View的集合(包括源码及demo)包括常见的支付、扫描、解锁动画、炫酷转盘式菜单等效果。A collection of Android cool custom views
Stars: ✭ 121 (-11.03%)
Mutual labels:  viewpager
Viewpagerindicator
A Simple View Pager Indicator with animations
Stars: ✭ 94 (-30.88%)
Mutual labels:  viewpager
Banner
Android Viewpager rotation control, application guide page controls, support vertical, horizontal cycle scrolling, extended from view support animation, indicator extension and so on;Android viewpager轮播图控件、app引导页控件,支持垂直、水平循环滚动,扩展自viewpager 支持动画,指示器扩展等。
Stars: ✭ 96 (-29.41%)
Mutual labels:  viewpager
Nested Fragments
Samples of nested fragments in various widgets (TabHost, ViewPager)
Stars: ✭ 115 (-15.44%)
Mutual labels:  viewpager
Parallaxscrollingview
Parallax scrolling either by offset or automatically.
Stars: ✭ 91 (-33.09%)
Mutual labels:  viewpager
Bubblepagerindicator
A view pager indicator view to deal with a large amount of pages.
Stars: ✭ 127 (-6.62%)
Mutual labels:  viewpager
Verticalviewpager
Vertically ViewPager and vertically transformer for Android.
Stars: ✭ 1,233 (+806.62%)
Mutual labels:  viewpager
Parallaxviewpager
a simple ViewPager with parallax effect
Stars: ✭ 103 (-24.26%)
Mutual labels:  viewpager
Banner
🔥🔥🔥Banner 2.0 来了!Android广告图片轮播控件,内部基于ViewPager2实现,Indicator和UI都可以自定义。
Stars: ✭ 11,682 (+8489.71%)
Mutual labels:  viewpager
Shviewpager
A simple view pager for iOS. Compatible with iOS 8.0 or later.
Stars: ✭ 127 (-6.62%)
Mutual labels:  viewpager
Pageboy
📖 A simple, highly informative page view controller
Stars: ✭ 1,652 (+1114.71%)
Mutual labels:  viewpager

ViewPager-Swift

An easy to use view pager library for iOS in Swift based on UIPageViewController and Scroll View along with multiple customization options and tap as well as swipe gesture for changing between pages.

What's New

This release 2.0.1 provides support for swift 4.2 & onwards. Use previous releases if you want to support older versions of swift.

This release contains changes which are not compatible with previous releases. I have tried to minimize the changes as much as possible to support backward compatibility.

Changelog:

  • Renamed ViewPagerControllerDataSource to ViewPagerDataSource
  • Renamed ViewPagerControllerDelegate to ViewPagerDelegate
  • Simplified the way to create ViewPager & its Options. See How to use section
  • Introduced property to show shadow below tab bar

Installation

NOTE: Release 2.0.1 provides support for Swift 4.2 & onwards . If you are using older versions of Swift, use previous releases.

This documentation is for Release 2.0.1. It slightly differs from previous releases. If you are looking for previous documentation, refer to swift4.0 branch.

Using Cocoapods

  1. Add following in your podfile
pod 'ViewPager-Swift'
  1. Type pod install in your terminal
  2. After installation, add import ViewPager_Swift module in your UIViewController, wherever you want to use ViewPager.

Manual Installation

Add

  1. ViewPager.swift
  2. ViewPagerOptions.swift
  3. ViewPagerTab.swift
  4. ViewPagerTabView.swift

files in your project.All files are present inside ViewPager-Swift/Core directory.

Screenshots

Screenshot-with-image-and-text Screenshot-with-text-only Screenshot-with-image-text-segmented

Contribution

You can always contribute to the project by creating a PR to development branch.

How to use

  1. Customize your View Pager with the help of ViewPagerOptions class
  2. Create ViewPager instance and set its options, datasource & delegates. That's it

You can find the implementation example on MainViewController.swift & TestViewController.swift files.

Step 1: During its initialization, default options are set for view pager. So just this single line is enough if you want to use default configuration.

let myOptions= ViewPagerOptions()

For further customization,

// Let's show image with text
myOptions.tabType = ViewPagerTabType.imageWithText

// If I want all my tabs to be of equal width
myOptions.distribution = ViewPagerOptions.Distribution.equal

// If I don't want my tab to get highlighted for page
myOptions.isTabHighlightAvailable = false

// If I want indicator bar to show below current page tab
myOptions.isTabIndicatorAvailable= true

// Oh! and let's change color of tab to red
myOptions.tabViewBackgroundDefaultColor = UIColor.redColor()

// and many more...

Step 2:

let viewPager = ViewPager(viewController: self)
viewPager.setOptions(options: options)
viewPager.setDataSource(dataSource: self)
viewPager.setDelegate(delegate: self)
viewPager.build()

That's it. You need to conform to ViewPagerDataSource protocol to provide necessary data such as number of tabs, ViewController to display etc. If you want , you can conform to ViewPagerDelegate protocol to receive additional feedbacks.

ViewPagerDataSource:

// Provide number of pages required
func numberOfPages() -> Int

// Provide ViewController for each page 
func viewControllerAtPosition(position:Int) -> UIViewController

// Provide info for each tab
func tabsForPages() -> [ViewPagerTab]

// Yayy! I can start from any page
optional func startViewPagerAtIndex()->Int

ViewPagerDelegate:

Called when transition to another view controller starts but is not completed

func willMoveToControllerAtIndex(index:Int)

Called when transiton to another view controller is completed

func didMoveToControllerAtIndex(index:Int)

Additional

You can also change the page programatically. Suppose you want to display 3rd page.

viewpager.displayViewController(atIndex: 2)    // Since index starts from 0

Note: If you want the viewpager to show specific page when it loads, use func startViewPagerAtIndex()->Int method from datasource.

Also, you can update any of the viewpager tab. Just update the ViewPagerTab array which you are providing through the datasource. and then call

viewpager.invalidateCurrentTabs()

Customization

You can perform lots of customization. If you want to look under the hoods, all the public variables inside ViewPagerOptions.swift file is customizable.

Notes:

Tab Indicator: Horizontal bar of small thickness which is displayed under tab for current page

TabView: Horizontal bar shown above viewpager which displays image or name of page.

Distribution: Enum which defines how the tabs should be laid out

Enums:

tabType:ViewPagerTabType

Determines which type of tab should be displayed.

basic: Tab containing only name of the page

image: Tab containing only image for the page

imageWithText: Tab showing image and name (below image) for the page

distribution: ViewPagerOptions.Distribution

Determines how the tabs should be laid out

normal: Tabs are laid out from Left to Right and is scrollable Width of each tab is equal to its content width + paddings set in options.

equal: Tabs are laid out from Left to Right and is scrollable. Width of all the tabs are equal. The width of all the tabs is equal to that of the largest ones.

segmented: Tabs are laid out from Left to Right in such a way that it doesnot exceeds the width of its container. So its not scrollable. i.e All the tabs fits within a view. Paddings are ignored.

Tab View and Tab Indicator:

Whether to highlight tab for current page or not, Default is false

isTabHighlightAvailable:Bool

Whether to display tab indicator or not, Default is true

isTabIndicatorAvailable:Bool

Height for tab, Default is 60

tabViewHeight:CGFloat

Background Color for whole tab View

tabViewBackgroundDefaultColor:UIColor

Background Color for current tab. Only displays if isTabViewHighlightAvailable is set to true

tabViewBackgroundHighlightColor:UIColor

Color for each page title

tabViewTextDefaultColor:UIColor

Color for text for current tab

tabViewTextHighlightColor:UIColor

Padding for each tab, Default is 10

tabViewPaddingLeft:CGFloat
tabViewPaddingRight:CGFloat

Height of tab indicator, Default is 3

tabIndicatorViewHeight:CGFloat

Background Color for tab Indicator

tabIndicatorViewBackgroundColor:UIColor

Font for the text inside tab

tabViewTextFont: UIFont

Size of the image inside tab. Used incase tabtype is image or imageWithText.

tabViewImageSize: CGSize

Top and Bottom margin for the image inside tab. Used incase tabtype is imageWithText. Else image is automatically centered inside tab.

tabViewImageMarginTop: CGFloat
tabViewImageMarginBottom: CGFloat

Displays shadow below the tab bar.

isTabBarShadowAvailable: Bool

Shadow Customization. Works only if isTabBarShadowAvailable is set to true.

shadowColor: UIColor
shadowOpacity: Float
shadowOffset: CGSize
shadowRadius: CGFloat

View Pager

Transition style for each page, Default is scroll

viewPagerTransitionStyle:UIPageViewControllerTransitionStyle

License

The MIT License (MIT)

Copyright (c) 2016 nrlnishan

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].