{"id":17160590,"url":"https://github.com/aloco/simplebutton","last_synced_at":"2025-03-17T14:16:25.223Z","repository":{"id":29387493,"uuid":"32922553","full_name":"aloco/SimpleButton","owner":"aloco","description":"Simple UIButton subclass with additional state change animations (e.g. backgroundColor) and missing features","archived":false,"fork":false,"pushed_at":"2021-09-08T13:59:24.000Z","size":2136,"stargazers_count":177,"open_issues_count":4,"forks_count":51,"subscribers_count":14,"default_branch":"master","last_synced_at":"2025-03-02T13:08:10.469Z","etag":null,"topics":["animation","ios","simplebutton","swift","uibutton-subclass"],"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/aloco.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":"2015-03-26T11:06:49.000Z","updated_at":"2024-08-15T03:08:02.000Z","dependencies_parsed_at":"2022-09-06T16:51:41.716Z","dependency_job_id":null,"html_url":"https://github.com/aloco/SimpleButton","commit_stats":null,"previous_names":[],"tags_count":13,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aloco%2FSimpleButton","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aloco%2FSimpleButton/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aloco%2FSimpleButton/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aloco%2FSimpleButton/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/aloco","download_url":"https://codeload.github.com/aloco/SimpleButton/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244047645,"owners_count":20389206,"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","ios","simplebutton","swift","uibutton-subclass"],"created_at":"2024-10-14T22:25:20.220Z","updated_at":"2025-03-17T14:16:25.169Z","avatar_url":"https://github.com/aloco.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"# SimpleButton\n\n![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)\n[![Build Status](https://travis-ci.org/aloco/SimpleButton.svg?branch=swift-3.0)](https://travis-ci.org/aloco/SimpleButton)\n![Swift 5](https://img.shields.io/badge/Swift-5-orange.svg)\n\n\nUIButton subclass with animated, state-aware attributes. Easy to subclass and configure! [Full API docs](http://aloco.github.io/SimpleButton/swift_output)\n\n\n\n![Sample](https://raw.githubusercontent.com/aloco/SimpleButton/master/Resources/example.gif)\n\n\n\n## Usage\n\nJust create your own `SimpleButton` subclass and configure your button attributes by overriding `configureButtonStyles`.\n\n```swift\nclass PrimaryButton: SimpleButton {\n\toverride func configureButtonStyles() {\n\t\tsuper.configureButtonStyles()\n    \tsetBorderWidth(4.0, for: .normal)\n\t\tsetBackgroundColor(UIColor(red: 52/255, green: 73/255, blue: 94/255, alpha: 1.0), for: .normal)\n\t\tsetBackgroundColor(UIColor(red: 44/255, green: 62/255, blue: 80/255, alpha: 1.0), for: .highlighted)\n\t\tsetBorderColor(UIColor(red: 44/255, green: 62/255, blue: 80/255, alpha: 1.0), for: .normal)\n\t\tsetScale(0.98, for: .highlighted)\n\t\tsetTitleColor(UIColor.whiteColor(), for: .normal)\n\t}\n}\n```\nFor usage in Interfacebuilder, just use your `SimpleButton` subclass as custom class for any `UIButton` element. All defined styles gets applied automatically.\n\nYou can also configure your button without a subclass directly inline.\n\n```swift\nlet awesomeButton = SimpleButton(type: .custom)\nawesomeButton.setBorderWidth(2.0, for: .normal)\nawesomeButton.setBorderColor(UIColor.redColor(), for: .highlighted)\nview.addSubview(awesomeButton)\n```\nNote that you should use `UIButtonType.custom` to avoid undesired effects.\n\nPlease checkout the example project for a detailed usage demo.\n\n\n#### @IBDesignable\n\nHave a look on [DesignableButton](Example/DesignableButton.swift) subclass within the Example Project for `@IBDesignable` usage.\n\n### Animation\nEach state change of `SimpleButton` animates by default. Sometimes you need to define which state transition should animate and which should happen immediately. Therefore you can control that behaviour with the `animated` and `animationDuration` parameters. \n\n```\nsetBorderWidth(4.0, for: .normal, animated: true, animationDuration: 0.2)\nsetBorderWidth(8.0, for: .highlighted, animated: false)\n```\nThis means, every state change to `.normal` animates the `borderWidth` to `4.0`. \nEvery state change to `.highlighted` changes instantly the `borderWidth` to `8.0` without animation.\n\n### Loading state\n\n`SimpleButton` has a custom `loading` state. You can toggle this state by setting `simpleButton.isLoading`. The button shows an `UIActivityIndicator` instead of the title when adding the `loading` state.\n\n```\nsimpleButton.setCornerRadius(20, for: SimpleButtonControlState.loading)\nsimpleButton.isLoading = true\n```\nIf you don´t like the default loading indicator, you can set your own `UIView` by doing\n```\nsimpleButton.loadingView = CustomAwesomeLoadingView()\n```\n\nPlease note, when using a custom loading view don´t forget to handle the position and initial add to subview by yourself to fit your needs.\n\n## Configurable attributes\n\nTake a look at the ```Setter for state attributes``` section of the [API Docs](http://aloco.github.io/SimpleButton/swift_output/Classes/SimpleButton.html#/Setter%20for%20state%20attributes) \n\n## Installation\n\nNote that SimpleButton is written in `swift 5` and may not be compatible with previous versions of swift. \n\n#### Swift Package Manager (Recommended)\n\nAdd the following dependency to your `Package.swift` file:\n\n```\n.package(url: \"https://github.com/allaboutapps/SimpleButton.git\", from: \"5.0.0\")\n```\n\n#### Carthage\n\nAdd the following line to your [Cartfile](https://github.com/Carthage/Carthage/blob/master/Documentation/Artifacts.md#cartfile).\n\n```\ngithub \"allaboutapps/SimpleButton\" ~\u003e 5.0\n```\n\nThen run `carthage update`.\n\n#### Manually\n\nJust drag and drop the `SimpleButton.swift` file into  your project.\n\n\n## Contributing\n\n* Create something awesome, make the code better, add some functionality,\n  whatever (this is the hardest part).\n* [Fork it](http://help.github.com/forking/)\n* Create new branch to make your changes\n* Commit all your changes to your branch\n* Submit a [pull request](http://help.github.com/pull-requests/)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faloco%2Fsimplebutton","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faloco%2Fsimplebutton","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faloco%2Fsimplebutton/lists"}