{"id":2495,"url":"https://github.com/rakaramos/OnOffButton","last_synced_at":"2025-08-03T00:31:46.040Z","repository":{"id":23107653,"uuid":"26461955","full_name":"rakaramos/OnOffButton","owner":"rakaramos","description":"On \u0026 Off by Creativedash","archived":false,"fork":false,"pushed_at":"2017-03-18T12:54:39.000Z","size":53,"stargazers_count":414,"open_issues_count":1,"forks_count":15,"subscribers_count":12,"default_branch":"master","last_synced_at":"2024-04-24T14:48:50.553Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/rakaramos.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":"2014-11-11T00:06:03.000Z","updated_at":"2024-04-03T01:42:53.000Z","dependencies_parsed_at":"2022-08-20T21:50:26.433Z","dependency_job_id":null,"html_url":"https://github.com/rakaramos/OnOffButton","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rakaramos%2FOnOffButton","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rakaramos%2FOnOffButton/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rakaramos%2FOnOffButton/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rakaramos%2FOnOffButton/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rakaramos","download_url":"https://codeload.github.com/rakaramos/OnOffButton/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":228510711,"owners_count":17931754,"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":[],"created_at":"2024-01-05T20:16:15.151Z","updated_at":"2024-12-06T18:30:30.731Z","avatar_url":"https://github.com/rakaramos.png","language":"Swift","readme":"Custom On/Off Animated UIButton, written in Swift. By Creativedash\n===========\n\n[![Version](https://img.shields.io/cocoapods/v/OnOffButton.svg?style=flat)](http://cocoapods.org/pods/OnOffButton)\n[![License](https://img.shields.io/cocoapods/l/OnOffButton.svg?style=flat)](http://cocoapods.org/pods/OnOffButton)\n[![Platform](https://img.shields.io/cocoapods/p/OnOffButton.svg?style=flat)](http://cocoapods.org/pods/OnOffButton)\n\n## About\nThis control is inspired on this Creative Dash dribbble:\n![alt tag](https://d13yacurqjgara.cloudfront.net/users/107759/screenshots/1631598/onoff.gif)\n\n## Swift Upgrade\n\nUse tags to fit your Swift version:\n\nSwift 3   =\u003e `1.4`\n\nSwift 2.3 =\u003e `1.3`\n\n## Installation\n\n### [Carthage]\n\n[Carthage]: https://github.com/Carthage/Carthage\n\nAdd the following to your Cartfile:\n\n```\ngithub \"rakaramos/OnOffButton\"\n```\n\nThen run `carthage update`.\n\nFollow the current instructions in [Carthage's README][carthage-installation]\nfor up to date installation instructions.\n\n[carthage-installation]: https://github.com/Carthage/Carthage#adding-frameworks-to-an-application\n\n### [CocoaPods]\n\n[CocoaPods]: http://cocoapods.org\n\nAdd the following to your [Podfile](http://guides.cocoapods.org/using/the-podfile.html):\n\n```ruby\npod 'OnOffButton'\n```\n\nYou will also need to make sure you're opting into using frameworks:\n\n```ruby\nuse_frameworks!\n```\n\nThen run `pod install` with CocoaPods 0.36 or newer.\n\n\n### Manually\nJust copy the `OnOffButton.swift` into your project.\n\n## Implementation\n\nAfter the installation, you can use it straight in code or with xib/storyboard.\n\n### In code:\n\n```swift\nclass ViewController: UIViewController {\n    \n    let onOffButton = OnOffButton()\n    \n    override func viewDidLoad() {\n        super.viewDidLoad()\n        \n        onOffButton.frame = CGRect(origin: .zero, size:CGSize(width: 100,height: 100))\n        // Adjust properties\n        onOffButton.lineWidth = 5\n        onOffButton.strokeColor = .whiteColor()\n        onOffButton.ringAlpha = 0.3\n        onOffButton.addTarget(self, action: #selector(ViewController.didTapOnOffButton), forControlEvents: .TouchUpInside)\n        \n        view.addSubview(onOffButton)\n    }\n    \n    func didTapOnOffButton() {\n        onOffButton.checked = !onOffButton.checked\n    }\n}\n```\n\n### Using `@IBDesignables`\n\nSet the `UIButton` class to use `OnOffButton`:\n\n![alt tag](https://cloud.githubusercontent.com/assets/7672056/14966575/95d2de1e-1089-11e6-8e22-6beb549c806b.png)\n\nConfigure the properties as you want: \n\n![alt tag](https://cloud.githubusercontent.com/assets/7672056/14966574/95d082cc-1089-11e6-9ef7-8215e390bb19.png)\n\nCreate an `IBAction`:\n\n```swift\n@IBAction func changeButtonState(sender: OnOffButton) {\n    sender.checked = !sender.checked\n}\n```\n\n\nProfit ;)\n\n## License\nReleased under the MIT license. See the LICENSE file for more info.\n","funding_links":[],"categories":["UI"],"sub_categories":["Button","Other free courses"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frakaramos%2FOnOffButton","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frakaramos%2FOnOffButton","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frakaramos%2FOnOffButton/lists"}