{"id":2650,"url":"https://github.com/tungvoduc/DTPagerController","last_synced_at":"2025-08-06T16:31:40.445Z","repository":{"id":56907951,"uuid":"103703581","full_name":"tungvoduc/DTPagerController","owner":"tungvoduc","description":"A fully customizable container view controller to display a set of ViewControllers in a horizontal scroll view. Written in Swift.","archived":false,"fork":false,"pushed_at":"2021-04-11T14:09:04.000Z","size":5841,"stargazers_count":289,"open_issues_count":6,"forks_count":42,"subscribers_count":9,"default_branch":"master","last_synced_at":"2024-11-24T01:52:26.713Z","etag":null,"topics":["cocoapods","ios","pager-controller","swift","swift-package-manager","swift4","swift5","xcode"],"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/tungvoduc.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":"2017-09-15T21:38:09.000Z","updated_at":"2024-07-11T15:50:22.000Z","dependencies_parsed_at":"2022-08-21T03:50:19.978Z","dependency_job_id":null,"html_url":"https://github.com/tungvoduc/DTPagerController","commit_stats":null,"previous_names":[],"tags_count":24,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tungvoduc%2FDTPagerController","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tungvoduc%2FDTPagerController/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tungvoduc%2FDTPagerController/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tungvoduc%2FDTPagerController/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tungvoduc","download_url":"https://codeload.github.com/tungvoduc/DTPagerController/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":228923711,"owners_count":17992567,"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":["cocoapods","ios","pager-controller","swift","swift-package-manager","swift4","swift5","xcode"],"created_at":"2024-01-05T20:16:19.257Z","updated_at":"2024-12-09T16:31:07.418Z","avatar_url":"https://github.com/tungvoduc.png","language":"Swift","funding_links":[],"categories":["UI","Libs","Swift","UI [🔝](#readme)"],"sub_categories":["Menu","UI","Other free courses"],"readme":"# DTPagerController\n\n[![Version](https://img.shields.io/cocoapods/v/DTPagerController.svg?style=flat)](http://cocoapods.org/pods/DTPagerController)\n[![License](https://img.shields.io/cocoapods/l/DTPagerController.svg?style=flat)](http://cocoapods.org/pods/DTPagerController)\n[![Platform](https://img.shields.io/cocoapods/p/DTPagerController.svg?style=flat)](http://cocoapods.org/pods/DTPagerController)\n\nThis is a control for iOS written in Swift. DTPagerController is simple to use and easy to customize. \n\n## Screenshots\n\n**Default segmented control**\n\n\u003cp align=\"left\" \u003e\n  \u003cimg src=\"Screenshots/Default.png\" title=\"Default segmented control\" width = \"320\"\u003e\n\u003c/p\u003e \n\n\n**Custom segmented control**\n\u003cp align=\"left\" \u003e\n  \u003cimg src=\"Screenshots/Custom.png\" title=\"Custom segmented control\" width = \"320\"\u003e\n\u003c/p\u003e \n\n## Usage\n\nDTPagerController is extremely easy to use. In order to display two view controllers inside a pager controller. All you have to do is this many lines of code.\n\n```swift\nlet viewController1 = ViewController()\nlet viewController2 = ViewController()\nlet pagerController = DTPagerController(viewControllers: [viewController1, viewController2])\n```\n### Update page index\nThere are 3 different ways to update selected page index programmatically.\n\n```swift\n\n// Update selected page index with animation\npagerController.selectedPageIndex = 1\n\n// Update selected page index with animation\npagerController.setSelectedPageIndex(1, animated: true)\n\n// Update selected page index without animation\npagerController.setSelectedPageIndex(1, animated: false)\n\n```\n\n### Custom UI\nDTPagerController is also customizable in case you want to implement your own UI.\n\n```swift\n\n// Change the height of segmented control\npagerController.preferredSegmentedControlHeight = 60\n\n// Change normal font of each segmented control\npagerController.font = UIFont.customFont(ofSize: 15)\n\n// Change selected font of each segmented control\npagerController.selectedFont = UIFont.boldCustomFont(ofSize: 15)\n\n// Change normal text color of each segmented control\npagerController.textColor = UIColor.black\n\n// Change selected text color of each segmented control\npagerController.selectedTextColor = UIColor.red\n\n// Change scroll indicator height\npagerController.perferredScrollIndicatorHeight = 3\n\n```\n\n### Custom segmented control\nFrom version **2.0.0**, DTPagerController supports custom segmented control. Therefore, instead of using default **DTSegmentedControl**, you can provide your own segmented control or any 3rd-party segmented control libraries available out there. All you have to do is making your custom UIControl conform **DTSegmentedControlProtocol**. For example, as shown in sample project, **HMSegmentedControl** is made to conform **DTSegmentedControlProtocol** by using extension:\n\n```swift\n\nextension HMSegmentedControl: DTSegmentedControlProtocol {\n    \n    public func setImage(_ image: UIImage?, forSegmentAt segment: Int) {\n        // Custom page control does not support\n    }\n    \n    public func setTitle(_ title: String?, forSegmentAt segment: Int) {\n        // Custom page control does not support\n    }\n    \n    public func setTitleTextAttributes(_ attributes: [AnyHashable : Any]?, for state: UIControlState) {\n        if state == UIControlState.normal {\n            titleTextAttributes = attributes\n        }\n        else if state == UIControlState.selected {\n            selectedTitleTextAttributes = attributes\n        }\n    }\n    \n}\n\n```\n\nThen we create new pager controller with the custom segmented control:\n\n```swift\n\ninit(viewControllers controllers: [UIViewController]) {\n        let segmentedControl = HMSegmentedControl(sectionTitles: [\"Page 1\", \"Page 2\", \"Page 3\"])\n        super.init(viewControllers: controllers, pageSegmentedControl: segmentedControl!)\n}\n\n```\n\nWhen using custom segmented control, it is recommneded to override/take a look at the following methods to customize behavior and appearance of each segments:\n\n```swift\n\n// Setup custom segmented control\nfunc setUpSegmentedControl(viewControllers: [UIViewController])\n\n// Update a custom appearance for segment\nfunc updateAppearanceForSegmentedItem(at index: Int)\n\n// Update a custom scroll indicator if exists\nfunc updateScrollIndicator(with offsetRatio: CGFloat, scrollView: UIScrollView)\n\n// Setup custom scroll indicator\nfunc setUpScrollIndicator()\n\n// Manually update segment title\nfunc setTitle(_ title: String?, forSegmentAt segment: Int)\n    \n// Manually update segment image\nfunc setImage(_ image: UIImage?, forSegmentAt segment: Int)\n\n```\n\n## Example\n\nTo run the example project, clone the repo, and run `pod install` from the Example directory first.\n\n## Requirements\n### iOS 9.0+\n\n## Installation\n### CocoaPods\nSimply add the following line to your Podfile:\n\n\nFor Swift 5:\n\n```ruby\npod 'DTPagerController'\n```\n\n\n\nFor Swift 4.2:\n\n```ruby\npod 'DTPagerController', '~\u003e 2.0.4'\n```\n\n### Swift package manager\n`DTPagerController` is available for SPM from version `3.0.2`.\nAdd the following to the dependencies of your `Package.swift`:\n\n```swift\n.package(url: \"https://github.com/tungvoduc/DTPagerController\", from: \"version\")\n```\n\n## Author\n\nTung Vo, tung98.dn@gmail.com\n\n## License\n\nDTPagerController is available under the MIT license. See the LICENSE file for more info.\n\n## Feedbacks \u0026 requests\n- Open an issue if you find a bug, make a proposal or simply need some help.\n- You can also contact me via [email](mailto:tung98.dn@gmail.com).","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftungvoduc%2FDTPagerController","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftungvoduc%2FDTPagerController","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftungvoduc%2FDTPagerController/lists"}