{"id":18646402,"url":"https://github.com/takescoop/swiftybutton","last_synced_at":"2025-04-04T16:16:03.603Z","repository":{"id":54777352,"uuid":"46310464","full_name":"TakeScoop/SwiftyButton","owner":"TakeScoop","description":"Simple and customizable button in Swift","archived":false,"fork":false,"pushed_at":"2021-08-07T05:53:38.000Z","size":240,"stargazers_count":551,"open_issues_count":10,"forks_count":43,"subscribers_count":45,"default_branch":"master","last_synced_at":"2025-03-28T15:09:29.875Z","etag":null,"topics":["ios","mobile","swift","uibutton","uikit"],"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/TakeScoop.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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":"2015-11-16T23:44:49.000Z","updated_at":"2025-03-11T13:15:41.000Z","dependencies_parsed_at":"2022-08-14T02:32:27.530Z","dependency_job_id":null,"html_url":"https://github.com/TakeScoop/SwiftyButton","commit_stats":null,"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TakeScoop%2FSwiftyButton","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TakeScoop%2FSwiftyButton/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TakeScoop%2FSwiftyButton/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TakeScoop%2FSwiftyButton/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/TakeScoop","download_url":"https://codeload.github.com/TakeScoop/SwiftyButton/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247208181,"owners_count":20901570,"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":["ios","mobile","swift","uibutton","uikit"],"created_at":"2024-11-07T06:19:39.555Z","updated_at":"2025-04-04T16:16:03.571Z","avatar_url":"https://github.com/TakeScoop.png","language":"Swift","readme":"SwiftyButton\n============\n\n**Maintainer(s):** [@nickm01](https://github.com/nickm01) [@pmacro](https://github.com/pmacro) [@aryamansharda](https://github.com/aryamansharda) \n\nSimple and customizable button in Swift.\n\n![](Examples/demo.gif)\n\n[![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage)\n\nInstallation\n------------\n\nCocoapods\n\n\n```\npod 'SwiftyButton'\n```\n\nCarthage\n\n\n```\ngithub 'TakeScoop/SwiftyButton'\n```\n\nUsage\n-----\n\n### Flat Button\n\n![](Examples/flat-button.gif)\n\n```swift\nlet button = FlatButton()\nbutton.color = .cyan\nbutton.highlightedColor = .blue\nbutton.cornerRadius  = 5\n```\n\n### Pressable Button\n\n![](Examples/pressable-button.gif)\n\n```swift\nlet button = PressableButton()\nbutton.colors = .init(button: .cyan, shadow: .blue)\nbutton.shadowHeight = 5\nbutton.cornerRadius = 5\n```\n\n### All Properties\n\nHere is a list of all the properties that you can modify. Those are all editable directly from Interface Builder. See `FlatButton.Defaults` or `PressableButton.Defaults` to set defaults for those properties.\n\n#### `FlatButton`\n\n```swift\nbutton.color = .cyan\nbutton.highlightedColor = .cyan\nbutton.selectedColor = .blue\nbutton.disabledButtonColor = .gray\nbutton.cornerRadius = 8\n```\n\n#### `PressableButton`\n\n```swift\nbutton.colors = .init(button: .cyan, shadow: .blue)\nbutton.disabledColors = .init(button: .gray, shadow: .darkGray)\nbutton.shadowHeight = 10\nbutton.cornerRadius = 8\nbutton.depth = 0.5 // In percentage of shadowHeight\n```\n\n### Interface Builder (Storyboard/XIB)\n\nAdd a `UIButton` as usual, then:\n - Modify the underlying class to `FlatButton/PressableButton`, and that the module is set to `SwiftyButton`\n - Make sure that the button type is set to `Custom`\n\n\u003cimg src=\"https://dl.dropboxusercontent.com/s/w48pvk6u15dbmv5/2017-02-07%20at%205.13%20PM.png\" width=\"30%\" style=\"vertical-align:top\"\u003e\n\u003cimg src=\"https://dl.dropboxusercontent.com/s/khuqvgfjk8yjs2v/2017-02-07%20at%205.13%20PM%20%281%29.png\" width=\"25%\" style=\"vertical-align:top\"\u003e\n\n\nDefaults\n--------\n\nYou can set defaults that will be applied for any new instance of SwiftyButton by modifying the `FlatButton.Defaults` or `PressableButton.Defaults` structure:\n\n```swift\nFlatButton.Defaults.color = .cyan\nPressableButton.Defaults.cornerRadius = 8\n...\n```\n\nCustom Content\n--------------\n\n![](Examples/custom.gif)\n\nUse `CustomPressableButton` to add custom content in a Swifty Button.\n\nThis is a subclass of `SwiftyButton` that exposes a content view that moves when the button state changes. All you have to do is add your views inside `button.contentView` and setup layout constraints relative to this view.\n\n### Install\n\n```\npod `SwiftyButton/CustomContent`\n```\n\n### Usage\n\nHere is how you would create a button similar to the one above (here we used [PureLayout](https://github.com/PureLayout/PureLayout) for constraints):\n\n```swift\nlet button = CustomPressableButton()\n\nlet indicator = UIActivityIndicatorView(activityIndicatorStyle: .white)\nbutton.contentView.addSubview(indicator)\nindicator.autoPinEdgesToSuperviewEdges(with: UIEdgeInsets(top: 10, left: 15, bottom: 10, right: 0), excludingEdge: .right)\nindicator.startAnimating()\n\nlet label = UILabel()\nbutton.contentView.addSubview(label)\nlabel.autoPinEdgesToSuperviewEdges(with: UIEdgeInsets(top: 10, left: 0, bottom: 10, right: 10), excludingEdge: .left)\nlabel.autoPinEdge(.left, to: .right, of: indicator, withOffset: 10)\nlabel.text = \"Loading...\"\nlabel.textColor = .white\n```\n\n### Known limitations\n\n - `PressableButton` only works with plain colors (no alpha / transparency) because of the way its background image is rendered. See [#2](https://github.com/TakeScoop/SwiftyButton/issues/2)\n - `PressableButton` manages title and image insets automatically (`titleEdgeInsets` and `imageEdgeInsets`). See [#5](https://github.com/TakeScoop/SwiftyButton/issues/15)\n    - User-specified inset values for `top` and `bottom` will be overridden.\n    - You may specify inset values for `left` and `right`.\n\nMore examples\n-------------\n\nLook at the [Examples](Examples/) folder to see more button examples.\n\nContribute\n----------\n\n### Publishing a new version\n\nHere's an example of a version bump: [bump to 0.8.0](https://github.com/TakeScoop/SwiftyButton/commit/d6e85522835db6f4c39e4c3ee8114d37f6dc9531).\n\nReplace `NEW_VERSION` with the version you're about to publish.\n\n - Checkout the `master` branch and ensure it's up-to-date.\n - Open `SwiftyButton.xcworkspace` and edit settings for the `SwiftyButton` target. Change the target version to `NEW_VERSION`.\n - Open `CHANGELOG.md` and add a new section `[NEW_VERSION]`. At the bottom of the document, copy a version anchor and link to the new version tag (which we'll create later). Insert a new empty `[master]` section on top.\n - Open `SwiftyButton.podspec` and edit `s.version` to `NEW_VERSION`.\n - Commit your changes as `Bump to NEW_VERSION`.\n - Create a new git tag named `NEW_VERSION` and push your commit + tag to Github.\n - Push the new pod version with `$ pod trunk push ./`\n\nLicense\n-------\n\nThis project is copyrighted under the MIT license. Complete license can be found here: \u003chttps://github.com/TakeScoop/SwiftyButton/blob/master/LICENSE\u003e\n\nCredits\n-------\n\n - Inspired by HTPressableButton: \u003chttps://github.com/herinkc/HTPressableButton\u003e\n - Colors used in examples come from \u003chttps://flatuicolors.com/\u003e\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftakescoop%2Fswiftybutton","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftakescoop%2Fswiftybutton","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftakescoop%2Fswiftybutton/lists"}