{"id":26281061,"url":"https://github.com/yonat/multitogglebutton","last_synced_at":"2025-04-05T18:09:58.905Z","repository":{"id":28166733,"uuid":"31667796","full_name":"yonat/MultiToggleButton","owner":"yonat","description":"Multiple state tap-to-toggle UIButton (like old camera flash button)","archived":false,"fork":false,"pushed_at":"2024-11-01T14:13:52.000Z","size":6318,"stargazers_count":84,"open_issues_count":0,"forks_count":18,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-29T17:11:21.074Z","etag":null,"topics":["swift","toggle","uibutton"],"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/yonat.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE.txt","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},"funding":{"github":["yonat"]}},"created_at":"2015-03-04T16:43:00.000Z","updated_at":"2025-01-10T08:36:33.000Z","dependencies_parsed_at":"2024-04-27T23:31:17.935Z","dependency_job_id":"a447f285-2d7b-4fcb-ad5d-a83d0d88fb41","html_url":"https://github.com/yonat/MultiToggleButton","commit_stats":{"total_commits":55,"total_committers":5,"mean_commits":11.0,"dds":"0.12727272727272732","last_synced_commit":"14c7987a9fd82afde2425cc040e1e4c782cc8900"},"previous_names":[],"tags_count":20,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yonat%2FMultiToggleButton","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yonat%2FMultiToggleButton/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yonat%2FMultiToggleButton/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yonat%2FMultiToggleButton/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yonat","download_url":"https://codeload.github.com/yonat/MultiToggleButton/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247378149,"owners_count":20929297,"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":["swift","toggle","uibutton"],"created_at":"2025-03-14T15:19:00.679Z","updated_at":"2025-04-05T18:09:58.881Z","avatar_url":"https://github.com/yonat.png","language":"Swift","readme":"# Multiple State Toggle UIButton\nA UIButton subclass that implements tap-to-toggle button text. (Like the camera flash and timer buttons)\n\n\n[![Swift Version][swift-image]][swift-url]\n[![Build Status][travis-image]][travis-url]\n[![License][license-image]][license-url]\n[![CocoaPods Compatible](https://img.shields.io/cocoapods/v/MultiToggleButton.svg)](https://img.shields.io/cocoapods/v/MultiToggleButton.svg)  \n[![Platform](https://img.shields.io/cocoapods/p/MultiToggleButton.svg?style=flat)](http://cocoapods.org/pods/MultiToggleButton)\n[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square)](http://makeapullrequest.com)\n\n\u003cp align=\"center\"\u003e\n\u003cimg src=\"screenshots/toggle.gif\"\u003e\n\u003c/p\u003e\n\n## Usage\n\nJust **create** it with the states, and it's good to go:\n\n```swift\nlet toggleButton = MultiToggleButton(image: myImage, states: [\"First\", \"Second\", \"Last\"])\n```\n\nGet and set the **current state**:\n\n```swift\nlet state = toggleButton.currentStateIndex\ntoggleButton.currentStateIndex = 0\n```\n\nAdd a **tap action** (in addition to the built-in state toggle):\n\n```swift\ntoggleButton.action = { (sender) -\u003e () in\n    doStuff(sender.currentStateIndex)\n}\n```\n\nSet **different colors** for different states (`nil` uses the button's ```tintColor```):\n\n```swift\ntoggleButton.colors = [nil, .gray, .red]\n```\n\nSet **different images** for different states:\n\n```swift\ntoggleButton.images = [myFirstImage, mySecondImage, myLastImage]\n```\n\nOr do it **all at once**:\n\n```swift\nlet toggleButton = ToggleButton(\n    images: [myFirstImage, mySecondImage, myLastImage],\n    states: [\"First\", \"Second\", \"Last\"],\n    colors: [nil, .gray, .red],\n    action: { (sender) -\u003e () in doStuff(sender.currentStateIndex) }\n)\n```\n\n## Installation\n\n### CocoaPods:\n\n```ruby\npod 'MultiToggleButton'\n```\n\nLegacy versions:\n\n| Swift version | MultiToggleButton version |\n| :---: | :---: |\n| 4.0 (Xcode 9.4) | `pod 'MultiToggleButton', '~\u003e 1.7.1'` |\n| 3 | `pod 'MultiToggleButton', '~\u003e 1.5.2'` |\n| 2.3 | `pod 'MultiToggleButton', '~\u003e 1.4.0'` |\n\n### Swift Package Manager:\n\n```swift\ndependencies: [\n    .package(url: \"https://github.com/yonat/MultiToggleButton\", from: \"1.8.8\")\n]\n```\n\n## Meta\n\n[@yonatsharon](https://twitter.com/yonatsharon)\n\n[https://github.com/yonat/MultiToggleButton](https://github.com/yonat/MultiToggleButton)\n\n[swift-image]:https://img.shields.io/badge/swift-4.2-orange.svg\n[swift-url]: https://swift.org/\n[license-image]: https://img.shields.io/badge/License-MIT-blue.svg\n[license-url]: LICENSE.txt\n[travis-image]: https://img.shields.io/travis/dbader/node-datadog-metrics/master.svg?style=flat-square\n[travis-url]: https://travis-ci.org/dbader/node-datadog-metrics\n[codebeat-image]: https://codebeat.co/badges/c19b47ea-2f9d-45df-8458-b2d952fe9dad\n[codebeat-url]: https://codebeat.co/projects/github-com-vsouza-awesomeios-com\n","funding_links":["https://github.com/sponsors/yonat"],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyonat%2Fmultitogglebutton","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyonat%2Fmultitogglebutton","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyonat%2Fmultitogglebutton/lists"}