{"id":15030495,"url":"https://github.com/yalantis/segmentio","last_synced_at":"2025-05-14T16:04:49.887Z","repository":{"id":44470515,"uuid":"62546975","full_name":"Yalantis/Segmentio","owner":"Yalantis","description":"Animated top/bottom segmented control written in Swift.","archived":false,"fork":false,"pushed_at":"2024-08-12T05:33:14.000Z","size":4189,"stargazers_count":2523,"open_issues_count":34,"forks_count":323,"subscribers_count":67,"default_branch":"master","last_synced_at":"2024-10-29T15:34:15.731Z","etag":null,"topics":["animation","carthage","cocoapods","ios","segmentio","swift","yalantis"],"latest_commit_sha":null,"homepage":"https://yalantis.com/","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/Yalantis.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":".github/contributing.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-07-04T08:54:51.000Z","updated_at":"2024-10-22T12:56:39.000Z","dependencies_parsed_at":"2024-11-19T09:00:41.538Z","dependency_job_id":"3e3b8118-1a18-49cb-b39d-1521550944ef","html_url":"https://github.com/Yalantis/Segmentio","commit_stats":{"total_commits":135,"total_committers":29,"mean_commits":4.655172413793103,"dds":0.8222222222222222,"last_synced_commit":"f12bae77afc7dbdc5d176cc01ab8f45eb3563e68"},"previous_names":[],"tags_count":20,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Yalantis%2FSegmentio","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Yalantis%2FSegmentio/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Yalantis%2FSegmentio/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Yalantis%2FSegmentio/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Yalantis","download_url":"https://codeload.github.com/Yalantis/Segmentio/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248154995,"owners_count":21056542,"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":["animation","carthage","cocoapods","ios","segmentio","swift","yalantis"],"created_at":"2024-09-24T20:13:30.071Z","updated_at":"2025-04-10T03:48:57.569Z","avatar_url":"https://github.com/Yalantis.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"## Segmentio\n[![Platform](http://img.shields.io/badge/platform-iOS-blue.svg?style=flat)](https://cocoapods.org/?q=segmentio) [![License](http://img.shields.io/badge/license-MIT-green.svg?style=flat)](https://github.com/Yalantis/Segmentio/blob/master/LICENSE) ![Swift 5](https://img.shields.io/badge/Swift-5-orange.svg) [![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage) ![Swift Package Manager](https://img.shields.io/badge/swiftpm-compatible-green.svg)\n\nAnimated top/bottom segmented control written in Swift.\n\n![Preview](https://github.com/Yalantis/Segmentio/blob/master/Assets/animation.gif)\n\nCheck this \u003ca href=\"https://dribbble.com/shots/2820372-Segmentio-Component\"\u003eproject on dribbble\u003c/a\u003e.\n\n## Requirements\n\n- Xcode 10\n- iOS 8.x+\n- Swift 5.0\n\n## Installation\n\n#### [CocoaPods](http://cocoapods.org)\n```ruby\nuse_frameworks! \n\npod 'Segmentio'\n```\n\n*CocoaPods v1.1.0 or later required*\n\n#### [Carthage](http://github.com/Carthage/Carthage)\n```ruby\ngithub \"Yalantis/Segmentio\"\n```\n\n## Usage\n#### Import `Segmentio` module\n```swift\nimport Segmentio\n```\n\n#### Init\nYou can initialize a `Segmentio` instance from code:\n\n```swift\nvar segmentioView: Segmentio!\n\nlet segmentioViewRect = CGRect(x: 0, y: 0, width: UIScreen.main.bounds.width, height: 125)\nsegmentioView = Segmentio(frame: segmentioViewRect)\nview.addSubview(segmentioView)\n```\n\nor\n\nadd a `UIView` instance in your .storyboard or .xib, set `Segmentio` class and connect `IBOutlet`:\n\n```swift\n@IBOutlet weak var segmentioView: Segmentio!\n```\n\n#### Setup `Segmentio`\n```swift\nsegmentioView.setup(\n\tcontent: [SegmentioItem],\n\tstyle: SegmentioStyle,\n\toptions: SegmentioOptions?\n)\n```\n\nTo start with default options you can just pass `nil` to the `options` parameter.\n\n```swift\nsegmentioView.setup(\n\tcontent: [SegmentioItem],\n\tstyle: SegmentioStyle,\n\toptions: nil\n)\n```\n\n\n#### Configuring items \nIn order to set items you need to create an array of `SegmentioItem` instances:\n\n```swift\nvar content = [SegmentioItem]()\n\nlet tornadoItem = SegmentioItem(\n\ttitle: \"Tornado\",\n\timage: UIImage(named: \"tornado\")\n)\ncontent.append(tornadoItem)\n```\n\n#### Handling selection\nYou can specify selected item manually:\n\n```swift\nsegmentioView.selectedSegmentioIndex = 0\n```\n\n#### Handling callback\n\n```swift\nsegmentioView.valueDidChange = { segmentio, segmentIndex in\n\tprint(\"Selected item: \", segmentIndex)\n}\n```\n\n#### Customization\n`Segmentio` can be customized by passing an instance of `SegmentioOptions` struct:\n\n```swift\nSegmentioOptions(\n            backgroundColor: .white,\n            segmentPosition: SegmentioPosition,\n            scrollEnabled: true,\n            indicatorOptions: SegmentioIndicatorOptions,\n            horizontalSeparatorOptions: SegmentioHorizontalSeparatorOptions,\n            verticalSeparatorOptions: SegmentioVerticalSeparatorOptions,\n            imageContentMode: .center,\n            labelTextAlignment: .center,\n            segmentStates: SegmentioStates\n)\n```\n\nSegment width rely on `SegmentioPosition` enum. Width can be fixed according to maximum visible items or dynamic according to segment's content size:\n\n```swift\nenum SegmentioPosition {\n    case dynamic\n    case fixed(maxVisibleItems: Int)\n}\n```\n\nSelection indicator can be customized by passing an instance of `SegmentioIndicatorOptions`:\n\n```swift\nSegmentioIndicatorOptions(\n            type: .bottom,\n            ratio: 1,\n            height: 5,\n            color: .orange\n)\n```\n\nHorizontal borders can be customized by passing an instance of `SegmentioHorizontalSeparatorOptions`:\n\n```swift\nSegmentioHorizontalSeparatorOptions(\n            type: SegmentioHorizontalSeparatorType.topAndBottom, // Top, Bottom, TopAndBottom\n            height: 1,\n            color: .gray\n)\n```\n\nSeparators between segments can be customized by passing an instance of  `SegmentioVerticalSeparatorOptions`:\n\n```swift\nSegmentioVerticalSeparatorOptions(\n            ratio: 0.6, // from 0.1 to 1\n            color: .gray\n)\n```\n\nIn order to set `SegmentioStates` you need to create a tuple of `SegmentioState` instances:\n\n```swift\nSegmentioStates(\n            defaultState: SegmentioState(\n                backgroundColor: .clear,\n                titleFont: UIFont.systemFont(ofSize: UIFont.smallSystemFontSize),\n                titleTextColor: .black\n            ),\n            selectedState: SegmentioState(\n                backgroundColor: .orange,\n                titleFont: UIFont.systemFont(ofSize: UIFont.smallSystemFontSize),\n                titleTextColor: .white\n            ),\n            highlightedState: SegmentioState(\n                backgroundColor: UIColor.lightGray.withAlphaComponent(0.6),\n                titleFont: UIFont.boldSystemFont(ofSize: UIFont.smallSystemFontSize),\n                titleTextColor: .black\n            )\n)\n```\n\n#### Let us know!\nWe’d be really happy if you sent us links to your projects where you use our component. Just send an email to github@yalantis.com And do let us know if you have any questions or suggestion regarding the animation.\n\nP.S. We’re going to publish more awesomeness wrapped in code and a tutorial on how to make UI for iOS (Android) better than better. Stay tuned!\n\n## License\n\nThe MIT License (MIT)\n\nCopyright © 2019 Yalantis\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\nall copies 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\nTHE SOFTWARE.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyalantis%2Fsegmentio","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyalantis%2Fsegmentio","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyalantis%2Fsegmentio/lists"}