{"id":15561253,"url":"https://github.com/nrlnishan/viewpager-swift","last_synced_at":"2025-04-13T06:28:10.833Z","repository":{"id":56926100,"uuid":"52346651","full_name":"nrlnishan/ViewPager-Swift","owner":"nrlnishan","description":"Simple View Pager library for swift using UIPageViewController and Scroll View","archived":false,"fork":false,"pushed_at":"2021-05-12T05:52:21.000Z","size":536,"stargazers_count":175,"open_issues_count":15,"forks_count":49,"subscribers_count":10,"default_branch":"master","last_synced_at":"2025-04-02T23:58:12.186Z","etag":null,"topics":["horizontal-slider","ios","page-slider","pagingmenu","swift","viewpager"],"latest_commit_sha":null,"homepage":"","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nrlnishan.png","metadata":{"files":{"readme":"Readme.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-02-23T09:21:03.000Z","updated_at":"2025-03-20T04:52:57.000Z","dependencies_parsed_at":"2022-08-20T22:50:18.255Z","dependency_job_id":null,"html_url":"https://github.com/nrlnishan/ViewPager-Swift","commit_stats":null,"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nrlnishan%2FViewPager-Swift","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nrlnishan%2FViewPager-Swift/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nrlnishan%2FViewPager-Swift/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nrlnishan%2FViewPager-Swift/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nrlnishan","download_url":"https://codeload.github.com/nrlnishan/ViewPager-Swift/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248673811,"owners_count":21143576,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["horizontal-slider","ios","page-slider","pagingmenu","swift","viewpager"],"created_at":"2024-10-02T16:06:46.821Z","updated_at":"2025-04-13T06:28:10.798Z","avatar_url":"https://github.com/nrlnishan.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n# ViewPager-Swift\n\nAn 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.\n\n## What's New\nThis release 2.0.1 provides support for swift 4.2 \u0026 onwards. Use previous releases if you want to support older versions of swift.\n\nThis 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.\n\nChangelog:\n\n- Renamed ViewPagerControllerDataSource to ViewPagerDataSource\n- Renamed ViewPagerControllerDelegate to ViewPagerDelegate\n- Simplified the way to create ViewPager \u0026 its Options. See How to use section\n- Introduced property to show shadow below tab bar \n\n\n## Installation\n\n\u003e**NOTE:** \n\u003e Release 2.0.1 provides support for Swift 4.2 \u0026 onwards . If you are using older versions of Swift, use previous releases.\n\u003e \n\u003e 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.\n\n**Using Cocoapods**\n\n1. Add following in your podfile\n```\npod 'ViewPager-Swift'\n```\n2. Type ```pod install``` in your terminal\n3. After installation, add ```import ViewPager_Swift``` module in your UIViewController, wherever you want to use ViewPager.\n\n**Manual Installation**\n\nAdd \n\n1. ViewPager.swift\n2. ViewPagerOptions.swift \n3. ViewPagerTab.swift\n4. ViewPagerTabView.swift \n\nfiles in your project.All files are present inside ViewPager-Swift/Core directory.\n\n## Screenshots \n\n![Screenshot-with-image-and-text](/Screenshots/Screenshot-1.png?raw=true)\n![Screenshot-with-text-only](/Screenshots/Screenshot-2.png?raw=true)\n![Screenshot-with-image-text-segmented](/Screenshots/Screenshot-3.png?raw=true)\n\n## Contribution\nYou can always contribute to the project by creating a PR to **development** branch.\n\n## How to use \n\n\u003e1. Customize your View Pager with the help of ViewPagerOptions class\n\u003e2. Create ViewPager instance and set its options, datasource \u0026 delegates. That's it\n\n\u003e You can find the implementation example on  MainViewController.swift \u0026 TestViewController.swift files.\n\n\n\n**Step 1:**\nDuring its initialization, default options are set for view pager. So just this single line is enough if you want to use default configuration.\n```\nlet myOptions= ViewPagerOptions()\n```\n\nFor further customization,\n```\n// Let's show image with text\nmyOptions.tabType = ViewPagerTabType.imageWithText\n\n// If I want all my tabs to be of equal width\nmyOptions.distribution = ViewPagerOptions.Distribution.equal\n\n// If I don't want my tab to get highlighted for page\nmyOptions.isTabHighlightAvailable = false\n\n// If I want indicator bar to show below current page tab\nmyOptions.isTabIndicatorAvailable= true\n\n// Oh! and let's change color of tab to red\nmyOptions.tabViewBackgroundDefaultColor = UIColor.redColor()\n\n// and many more...\n```\n\n**Step 2:**\n```\nlet viewPager = ViewPager(viewController: self)\nviewPager.setOptions(options: options)\nviewPager.setDataSource(dataSource: self)\nviewPager.setDelegate(delegate: self)\nviewPager.build()\n```\n\nThat'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.\n\n**ViewPagerDataSource:**\n\n```\n// Provide number of pages required\nfunc numberOfPages() -\u003e Int\n\n// Provide ViewController for each page \nfunc viewControllerAtPosition(position:Int) -\u003e UIViewController\n\n// Provide info for each tab\nfunc tabsForPages() -\u003e [ViewPagerTab]\n\n// Yayy! I can start from any page\noptional func startViewPagerAtIndex()-\u003eInt\n```\n\n**ViewPagerDelegate:**\n\nCalled when transition to another view controller starts but is not completed\n```\nfunc willMoveToControllerAtIndex(index:Int)\n```\nCalled when transiton to another view controller is completed\n```\nfunc didMoveToControllerAtIndex(index:Int)\n```\n\n**Additional**\n\nYou can also change the page programatically. Suppose you want to display 3rd page.\n\n```\nviewpager.displayViewController(atIndex: 2)    // Since index starts from 0\n```\n\nNote: If you want the viewpager to show specific page when it loads, use ``` func startViewPagerAtIndex()-\u003eInt ``` method from datasource.\n\n\nAlso, you can update any of the viewpager tab. Just update the ViewPagerTab array which you are providing through the datasource. and then call\n```\nviewpager.invalidateCurrentTabs()\n```\n\n\n## Customization \nYou can perform lots of customization. If you want to look under the hoods, all the **public variables** inside **ViewPagerOptions.swift** file is customizable.\n\n\u003e**Notes:**\n\u003e\n\u003e**Tab Indicator:** Horizontal bar of small thickness which is displayed under tab for current page\n\n\u003e**TabView:** Horizontal bar shown above viewpager which displays image or name of page.\n\u003e\n\u003e**Distribution:** Enum which defines how the tabs should be laid out\n\n\n**Enums:**\n\n```\ntabType:ViewPagerTabType\n```\nDetermines which type of tab should be displayed.\n\n\u003e**basic:** Tab containing only name of the page\n\n\u003e**image:** Tab containing only image for the page\n\n\u003e**imageWithText:** Tab showing image and name (below image) for the page\n\n```\ndistribution: ViewPagerOptions.Distribution\n```\nDetermines how the tabs should be laid out\n\n\u003e**normal**: \n\u003eTabs are laid out from Left to Right and is scrollable \n\u003e Width of each tab is equal to its content width + paddings set in options.\n\n\u003e**equal**:\n\u003eTabs 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.\n\n\u003e**segmented**:\n\u003eTabs 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.\n\n**Tab View and Tab Indicator:**\n\nWhether to highlight tab for current page or not, Default is false\n```\nisTabHighlightAvailable:Bool\n```\nWhether to display tab indicator or not, Default is true\n```\nisTabIndicatorAvailable:Bool\n```\n\nHeight for tab, Default is 60\n```\ntabViewHeight:CGFloat\n```\nBackground Color for whole tab View\n```\ntabViewBackgroundDefaultColor:UIColor\n```\nBackground Color for current tab. Only displays if isTabViewHighlightAvailable is set to true\n```\ntabViewBackgroundHighlightColor:UIColor\n```\nColor for each page title \n```\ntabViewTextDefaultColor:UIColor\n```\nColor for text for current tab\n```\ntabViewTextHighlightColor:UIColor\n```\nPadding for each tab, Default is 10\n```\ntabViewPaddingLeft:CGFloat\ntabViewPaddingRight:CGFloat\n```\nHeight of tab indicator, Default is 3\n```\ntabIndicatorViewHeight:CGFloat\n```\nBackground Color for tab Indicator\n```\ntabIndicatorViewBackgroundColor:UIColor\n```\nFont for the text inside tab\n```\ntabViewTextFont: UIFont\n```\nSize of the image inside tab. Used incase tabtype is image or imageWithText.\n```\ntabViewImageSize: CGSize\n```\nTop and Bottom margin for the image inside tab. Used incase tabtype is imageWithText. Else image is automatically centered inside tab.\n```\ntabViewImageMarginTop: CGFloat\ntabViewImageMarginBottom: CGFloat\n```\n\nDisplays shadow below the tab bar.\n```\nisTabBarShadowAvailable: Bool\n```\n\nShadow Customization. Works only if ```isTabBarShadowAvailable``` is set to true.\n```\nshadowColor: UIColor\nshadowOpacity: Float\nshadowOffset: CGSize\nshadowRadius: CGFloat\n```\n\n\n**View Pager**\n\nTransition style for each page, Default is scroll\n```\nviewPagerTransitionStyle:UIPageViewControllerTransitionStyle\n```\n\n\n## License \nThe MIT License (MIT)\n\nCopyright (c) 2016 nrlnishan\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnrlnishan%2Fviewpager-swift","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnrlnishan%2Fviewpager-swift","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnrlnishan%2Fviewpager-swift/lists"}