{"id":15037350,"url":"https://github.com/tapptitude/ttsegmentedcontrol","last_synced_at":"2025-05-16T19:03:47.366Z","repository":{"id":56923400,"uuid":"69257199","full_name":"tapptitude/TTSegmentedControl","owner":"tapptitude","description":"An elegant, animated and customizable segmented control for iOS created by Tapptitude","archived":false,"fork":false,"pushed_at":"2023-09-14T12:40:35.000Z","size":6401,"stargazers_count":598,"open_issues_count":9,"forks_count":99,"subscribers_count":17,"default_branch":"master","last_synced_at":"2025-04-12T17:46:49.705Z","etag":null,"topics":["animated","cocoapods","customizable","interface-builder","ios","segmented-controls","swift","swift3","ui","uicomponent","uikit","xcode"],"latest_commit_sha":null,"homepage":"https://tapptitude.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/tapptitude.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-09-26T14:13:34.000Z","updated_at":"2025-04-03T09:50:24.000Z","dependencies_parsed_at":"2024-06-18T20:13:36.867Z","dependency_job_id":"13ff8793-76d5-4aa3-9b99-f119c8d64664","html_url":"https://github.com/tapptitude/TTSegmentedControl","commit_stats":{"total_commits":57,"total_committers":11,"mean_commits":5.181818181818182,"dds":0.7719298245614035,"last_synced_commit":"113629ddbf4453d488ac5b88b67ac431f1e1e3f0"},"previous_names":[],"tags_count":15,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tapptitude%2FTTSegmentedControl","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tapptitude%2FTTSegmentedControl/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tapptitude%2FTTSegmentedControl/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tapptitude%2FTTSegmentedControl/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tapptitude","download_url":"https://codeload.github.com/tapptitude/TTSegmentedControl/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254592368,"owners_count":22097011,"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":["animated","cocoapods","customizable","interface-builder","ios","segmented-controls","swift","swift3","ui","uicomponent","uikit","xcode"],"created_at":"2024-09-24T20:34:24.275Z","updated_at":"2025-05-16T19:03:47.308Z","avatar_url":"https://github.com/tapptitude.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"# TTSegmentedControl\n![](https://img.shields.io/badge/Swift-5.0-green.svg?style=flat)\n![](https://img.shields.io/badge/Swift-4.0-green.svg?style=flat)\n![](https://img.shields.io/badge/Swift-3.0-green.svg?style=flat)\n[![Platform](https://img.shields.io/cocoapods/p/TTSegmentedControl.svg)](https://cocoapods.org/pods/TTSegmentedControl)\n[![Version](https://img.shields.io/cocoapods/v/TTSegmentedControl.svg)](https://cocoapods.org/pods/TTSegmentedControl)\n[![License](https://img.shields.io/cocoapods/l/TTSegmentedControl.svg?style=flat)](http://cocoapods.org/pods/TTSegmentedControl)\n[![Twitter](https://img.shields.io/badge/Twitter-@Tapptitude-blue.svg?style=flat)](http://twitter.com/Tapptitude)\n\n## About\nAn elegant, animated and customizable segmented control for iOS.\n\nThis project is maintained by Tapptitude, a mobile app development agency specialized in building high-quality iOS and Android mobile apps, for startups and brands alike. A lively team of skilled app developers and app designers based in Europe, we provide full-stack mobile app development services to entrepreneurs looking to innovate on mobile. \n\n![](Resources/TTSegmentedControl.gif)\n\n\n## Features:\n- Variable number of items \n- Animated transition\n- Bounce animation\n- Fully configurable (color, gradient, shadow, border, corner radius)\n- Designable into Interface Builder\n\n## Requirements\n\n- iOS 13.0+\n- Xcode 11+\n\n## Installation\n\n_Swift Package Manager_\n\n```\ndependencies: [\n    .package(url: \"https://github.com/dumitruigor/TTSegmentedControl.git\", branch: \"swiftPackage\")\n]\n```\n\n_CocoaPods_\n\n```ruby\n  pod 'TTSegmentedControl', :git =\u003e 'https://github.com/dumitruigor/TTSegmentedControl.git', :branch =\u003e 'swiftPackage'\n```\n\n_Carthage_\n\n```\ngithub \"tapptitude/TTSegmentedControl\"\n```\n\n_Manually_\n\nAdd the TTSegmentedControl to your project.\n\n## Usage\n\n- SwiftUI:\n\n```swift\nlet titles = [\"Title1\", \"Title2\"].map { TTSegmentedControlTitle(text: $0) }\n\nTTSwiftUISegmentedControl(titles: titles, selectedIndex: $selectedIndex)\n```\n\n- UIKit:\n\n```swift\nlet titles = [\"Title1\", \"Title2\"].map { TTSegmentedControlTitle(text: $0) }\n\nlet segmentedControl = TTSegmentedControl()\nsegmentedControl.titles = titles\nview.addSubview(segmentedControl)\n```\n\n## How to customize?\n\nIn order to customize the segmented control you'll have to edit it's properties:\n\n```swift\n//UIKit\nsegmentedControl.selectionViewFillType = .fillSegment\nsegmentedControl.titleDistribution = .equalSpacing \nsegmentedControl.isDragEnabled = true \nsegmentedControl.isSizeAdjustEnabled = true\nsegmentedControl.isSwitchBehaviorEnabled = false\nsegmentedControl.containerBackgroundColor = .white\nsegmentedControl.cornerRadius = .constant(value: 15)\nsegmentedControl.cornerCurve = .continous\nsegmentedControl.padding = .init(width: 2, height: 2)\n\n//SwiftUI\nTTSwiftUISegmentedControl(titles: titles)\n    .titleDistribution(.equalSpacing)\n    .padding(.init(width: 2, height: 2))\n    .isDragEnabled(true)\n    .containerBackgroundColor(.white)\n    .selectionViewColor(.blue)\n    .cornerRadius(.constant(value: 15))\n    .isSwitchBehaviorEnabled(false)\n)\n```\n\nYou can even disable animation or/and bounce effect:\n\n```swift\n//UIKit\nsegmentedControl.animationOptions = nil \nsegmentedControl.bounceAnimationOptions = nil\n\n//SwiftUI\nTTSwiftUISegmentedControl(titles: titles)\n    .animationOptions(nil)\n    .bounceAnimationOptions(nil)\n)\n```\n\nOr you can edit them:\n\n```swift\n\nlet animationOptions = TTSegmentedControlAnimationOption(duration: 0.5, options: .curveEaseInOut)\nlet bounceAnimationOptions = TTSegmentedControlBounceOptions(springDamping: 0.7, springInitialVelocity: 0.2)\n\n//UIKit\nsegmentedControl.animationOptions = animationOptions\nsegmentedControl.bounceAnimationOptions = bounceAnimationOptions\n\n//SwiftUI\nTTSwiftUISegmentedControl(titles: titles)\n    .animationOptions(animationOptions)\n    .bounceAnimationOptions(bounceAnimationOptions)\n)\n```\n\nThe segmentedControl titles can be customized:\n\n```swift\nlet title1 = TTSegmentedControlTitle(\n    text: \"Title 1\",\n    defaultColor: .black,\n    defaultFont: .systemFont(ofSize: 12),\n    selectedColor: .white,\n    selectedFont: .systemFont(ofSize: 13)\n)\n\nlet title2 = TTSegmentedControlTitle(\n    text: \"Title 2\",\n    defaultColor: .black,\n    defaultFont: .systemFont(ofSize: 12),\n    selectedColor: .white,\n    selectedFont: .systemFont(ofSize: 13)\n)\n\n//UIKit\nsegmentedControl.titles = [title1, title2]\n\n//SwiftUI\nTTSwiftUISegmentedControl(titles: [title1, title2])\n```\n\nInstead of text the titles can be initialized with NSAttributedString objects:\n\n```swift\nlet title1 = TTSegmentedControlTitle(\n    defaultAttributedText: attributedText1,\n    selectedAttributedText: attributedText2\n)\n\nlet title2 = TTSegmentedControlTitle(\n    defaultAttributedText: attributedText3,\n    selectedAttributedText: attributedText4\n)\n\n//UIKit\nsegmentedControl.titles = [title1, title2]\n\n//SwiftUI\nTTSwiftUISegmentedControl(titles: [title1, title2])\n```\n\nYou can add image instead of title:\n\n![](Resources/Image_with_attributes_3.png)\n\n```swift\nlet title1 = TTSegmentedControlTitle(\n    defaultImageName: \"default_image_1\",\n    selectedImageName: \"selected_image_1\"\n)\n\nlet title2 = TTSegmentedControlTitle(\n    defaultImageName: \"default_image_2\",\n    selectedImageName: \"selected_image_2\"\n)\n\nlet title3 = TTSegmentedControlTitle(\n    defaultImageName: \"default_image_3\",\n    selectedImageName: \"selected_image_3\"\n)\n\n//UIKit\nsegmentedControl.titles = [title1, title2, title3]\n\n//SwiftUI\nTTSwiftUISegmentedControl(titles: [title1, title2, title3])\n```\n\nThe image sizes can be customized for each title:\n\n![](Resources/Image_with_attributes.png)\n\n```swift\nlet title1 = TTSegmentedControlTitle(\n    defaultImageName: \"default_image_1\",\n    selectedImageName: \"selected_image_1\",\n    imageSize: CGSize(width: 10, height: 10)\n)\n\nlet title2 = TTSegmentedControlTitle(\n    defaultImageName: \"default_image_2\",\n    selectedImageName: \"selected_image_2\",\n    imageSize: CGSize(width: 30, height: 30)\n)\n\nlet title3 = TTSegmentedControlTitle(\n    defaultImageName: \"default_image_3\",\n    selectedImageName: \"selected_image_3\",\n    imageSize: CGSize(width: 20, height: 20)\n)\n\n//UIKit\nsegmentedControl.titles = [title1, title2, title3]\n\n//SwiftUI\nTTSwiftUISegmentedControl(titles: [title1, title2, title3])\n```\n\nThe texts can be combined with the images:\n\n![](Resources/Image_with_attributes_2.png)\n\n```swift\nlet title1 = TTSegmentedControlTitle(\n    text: \"Facebook\",\n    defaultImageName: \"default_image_1\",\n    selectedImageName: \"selected_image_1\",\n    imageSize: CGSize(width: 5, height: 5),\n    imagePosition: .left\n)\n\nlet title2 = TTSegmentedControlTitle(\n    text: \"Youtube\",\n    defaultImageName: \"default_image_2\",\n    selectedImageName: \"selected_image_2\",\n    imageSize: CGSize(width: 8, height: 8),\n    imagePosition: .bottom\n)\n\nlet title3 = TTSegmentedControlTitle(\n    text: \"Twitter\",\n    defaultImageName: \"default_image_2\",\n    selectedImageName: \"selected_image_2\",\n    imageSize: CGSize(width: 8, height: 7),\n    imagePosition: .top\n)\n\n//UIKit\nsegmentedControl.titles = [title1, title2, title3]\n\n//SwiftUI\nTTSwiftUISegmentedControl(titles: [title1, title2, title3])\n```\n## Contribution\n\nFeel free to Fork, submit Pull Requests or send us your feedback and suggestions!\n\n\n## License\n\nTTSegmentedControl is available under the MIT license. See the LICENSE file for more info.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftapptitude%2Fttsegmentedcontrol","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftapptitude%2Fttsegmentedcontrol","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftapptitude%2Fttsegmentedcontrol/lists"}