{"id":2184,"url":"https://github.com/rolandleth/LTHRadioButton","last_synced_at":"2025-08-06T16:30:58.025Z","repository":{"id":44781061,"uuid":"71577119","full_name":"rolandleth/LTHRadioButton","owner":"rolandleth","description":"A radio button with a pretty animation","archived":false,"fork":false,"pushed_at":"2024-04-12T06:03:13.000Z","size":46,"stargazers_count":370,"open_issues_count":0,"forks_count":29,"subscribers_count":5,"default_branch":"master","last_synced_at":"2024-12-06T15:54:26.903Z","etag":null,"topics":["animation","checkbox","cocoapods","radio-buttons","swift"],"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/rolandleth.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":{"ko_fi":"rolandleth","patreon":"rolandleth","custom":"https://paypal.me/rolandleth"}},"created_at":"2016-10-21T15:21:32.000Z","updated_at":"2024-10-17T01:34:00.000Z","dependencies_parsed_at":"2024-04-27T23:31:18.734Z","dependency_job_id":"53a61bfc-40eb-4568-8d4c-f33d1932b4db","html_url":"https://github.com/rolandleth/LTHRadioButton","commit_stats":{"total_commits":23,"total_committers":5,"mean_commits":4.6,"dds":"0.30434782608695654","last_synced_commit":"d820f9084e4354440dc84975a536b13b38fb3ab0"},"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rolandleth%2FLTHRadioButton","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rolandleth%2FLTHRadioButton/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rolandleth%2FLTHRadioButton/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rolandleth%2FLTHRadioButton/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rolandleth","download_url":"https://codeload.github.com/rolandleth/LTHRadioButton/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":228923687,"owners_count":17992566,"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","checkbox","cocoapods","radio-buttons","swift"],"created_at":"2024-01-05T20:16:06.916Z","updated_at":"2024-12-09T16:31:00.555Z","avatar_url":"https://github.com/rolandleth.png","language":"Swift","funding_links":["https://ko-fi.com/rolandleth","https://patreon.com/rolandleth","https://paypal.me/rolandleth"],"categories":["Libs","UI","UI [🔝](#readme)"],"sub_categories":["UI","Other free courses","Font","Other Testing"],"readme":"# LTHRadioButton\n\nSlightly inspired by Google's material radio button.\n\nThe clip below has 3 sections: full speed, 25% and 10%, but after converting it to GIF, it actually made it longer, so the 10% part takes a really long time. [Here's][1] an mp4 link; try with Chrome if Safari doesn't work - for me it doesn't.\n\n![][image-1]\n\n## How to install\n\n### Swift Package Manager\n\n**NOTE**: _These instructions are intended for usage on Xcode 11 and higher. Xcode 11 is the first version of Xcode that integrates Swift Package Manager and makes it way easier to use than it was at the command line. If you are using older versions of Xcode, we recommend using CocoaPods._\n\n1. Go to File \u003e Swift Packages \u003e Add Package Dependency...\n2. Paste the URL to the `LTHRadioButton` repo on GitHub (https://github.com/rolandleth/LTHRadioButton.git) into the search bar, then hit the Next button:\n3. Select what version you want to use, then hit next (Xcode will automatically suggest the current version Up to Next Major).\n4. Select the `LTHRadioButton` library and then hit finish.\n5. You're done!\n\n#### CocoaPods\n\n[CocoaPods][2] is a dependency manager for Cocoa projects. You can install it with the following terminal command:\n\n```\ngem install cocoapods\n```\n\nTo integrate `LTHRadioButton` into your Xcode project using CocoaPods, specify it in your Podfile:\n\n```ruby\nsource 'https://github.com/CocoaPods/Specs.git'\nplatform :ios, '9.0'\nuse_frameworks!\n\ntarget '\u003cYour Target Name\u003e' do\n  pod 'LTHRadioButton'\nend\n```\n\nThen, run the following terminal command:\n\n```\npod install\n```\n\n#### Manual\n\nDrag `LTHRadioButton.swift` from the `source` folder into your Xcode project.\n\n## How to use\n\nThe initializer takes up to 3 params: a `diameter`, a `selectedColor`, and a `deselectedColor`. All of them are optional:\n\n- `diameter` defaults to `18`\n- `selectedColor` defaults to a light blue\n- `deselectedColor` defaults to `UIColor.lightGray`\n\nIt doesn't use Auto Layout internally, but after initialization it will have a proper size, so you can simply create constraints based on its `frame.width` and `frame.height`.\n\n#### Properties\n\n`selectedColor` and `deselectedColor` have been made publicly customizable for cases like a `tableView` with alternating row and radio colors, where the `tableView` might dequeue a cell with one color for displaying a cell with a different color.\n\n`isSelected` - Indicates whether the radio button is selected.\n\n`useTapGestureRecognizer` - Indicates whether a tap gesture recognizer should be added to the control when setting callbacks. This defaults to `true` just so that `onSelect` and `onDeselect` can add the gesture recognizer automatically, but the recognizer is **not** added by default.\n\n- Settings this to `true` will also add the required `UITapGestureRecognizer` if needed.\n- Settings this to `false` will also remove the `UITapGestureRecognizer` if it was previously added.\n\n#### Methods\n\n```swift\ninit(diameter: CGFloat = 18, selectedColor: UIColor? = nil, deselectedColor: UIColor? = nil) // Colors default internally if nil.\nfunc select(animated: Bool = true) // Selects the radio button.\nfunc deselect(animated: Bool = true) // Deselects the radio button.\n```\n\n### Callbacks\n\nYou can make use of the `onSelect` and `onDeselect` methods to add closures to be run when selecting/deselecting the control. Since these closures make most sense for taps and because there are no recognizers by default, these methods will also add one (and only one) `UITapGestureRecognizer` to the control to handle the taps; the closure calls happen right as the animations begin.\n\nIf you'd like to use the callbacks but don't need the tap gesture recognizer, you can set `useTapGestureRecognizer` to `false`.\n\n### Example\n\n```swift\nlet radioButton = LTHRadioButton(selectedColor: .red)\ncontainer.addSubview(radioButton)\n\nradioButton.translatesAutoresizingMaskIntoConstraints = false\nNSLayoutConstraint.activate([\n  radioButton.centerYAnchor.constraint(equalTo: container.centerYAnchor),\n  radioButton.leadingAnchor.constraint(equalTo: container.leadingAnchor, constant: 16),\n  radioButton.heightAnchor.constraint(equalToConstant: radioButton.frame.height),\n  radioButton.widthAnchor.constraint(equalToConstant: radioButton.frame.width)]\n)\n\nradioButton.onSelect {\n  print(\"I'm selected.\")\n}\n\nradioButton.onDeselect {\n  print(\"I'm deselected.\")\n}\n\n[...]\n\nradioButton.select() // I'm selected.\n\n[...]\n\nradioButton.deselect(animated: false) // I'm deselected.\n```\n\n## Apps using this control\n\nIf you're using this control, I'd love hearing from you!\n\n## License\n\nLicensed under MIT. If you'd like (or need) a license without attribution, don't hesitate to [contact me][3].\n\n[1]: https://rolandleth.com/images/radio-button/video.mp4\n[2]: https://cocoapods.org\n[3]: mailto:roland@hey.com\n[image-1]: https://rolandleth.com/images/radio-button/gif.gif\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frolandleth%2FLTHRadioButton","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frolandleth%2FLTHRadioButton","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frolandleth%2FLTHRadioButton/lists"}