{"id":13637811,"url":"https://github.com/sjc-bui/QBIndicatorButton","last_synced_at":"2025-04-19T17:31:50.758Z","repository":{"id":49729786,"uuid":"368768747","full_name":"sjc-bui/QBIndicatorButton","owner":"sjc-bui","description":":heavy_check_mark: Simple way to display activity indicator inside the button.","archived":false,"fork":false,"pushed_at":"2021-06-10T08:35:08.000Z","size":12443,"stargazers_count":10,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-10-01T00:41:15.627Z","etag":null,"topics":["activity-indicator","button","cocoapods","gradient-button","indicator-button","loading","loading-button","storyboard","swift","swift5","uibutton","uibutton-extension","xcode"],"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/sjc-bui.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":"2021-05-19T06:38:47.000Z","updated_at":"2024-07-24T16:34:55.000Z","dependencies_parsed_at":"2022-08-30T19:01:23.341Z","dependency_job_id":null,"html_url":"https://github.com/sjc-bui/QBIndicatorButton","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sjc-bui%2FQBIndicatorButton","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sjc-bui%2FQBIndicatorButton/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sjc-bui%2FQBIndicatorButton/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sjc-bui%2FQBIndicatorButton/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sjc-bui","download_url":"https://codeload.github.com/sjc-bui/QBIndicatorButton/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223435256,"owners_count":17144466,"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":["activity-indicator","button","cocoapods","gradient-button","indicator-button","loading","loading-button","storyboard","swift","swift5","uibutton","uibutton-extension","xcode"],"created_at":"2024-08-02T01:00:34.215Z","updated_at":"2024-11-09T08:30:21.417Z","avatar_url":"https://github.com/sjc-bui.png","language":"Swift","funding_links":[],"categories":["Content"],"sub_categories":["Button"],"readme":"# QBIndicatorButton\n\n[![Build Status](https://www.travis-ci.com/sjc-bui/QBIndicatorButton.svg?branch=master)](https://www.travis-ci.com/sjc-bui/QBIndicatorButton)\n[![Version](https://img.shields.io/cocoapods/v/QBIndicatorButton.svg?style=flat)](https://cocoapods.org/pods/QBIndicatorButton)\n[![License](https://img.shields.io/cocoapods/l/QBIndicatorButton.svg?style=flat)](https://cocoapods.org/pods/QBIndicatorButton)\n[![Platform](https://img.shields.io/cocoapods/p/QBIndicatorButton.svg?style=flat)](https://cocoapods.org/pods/QBIndicatorButton)\n\nCustom of UIButton in Swift.\n\n\u003cimg alt=\"Screenshot\" src=\"https://github.com/sjc-bui/QBIndicatorButton/blob/master/Example/Screenshots/QBIndicatorButton.gif\" width=\"300\"/\u003e\n\n## Example\n\nTo run the example project, clone the repo, and run `pod install` from the Example directory first.\n\n## Features\n- Edit button style from storyboard or code\n- Set a gradient background and gradient directions\n- Customize the corner radius, border color, border width\n- Customize the button animation: scale, scale duration\n- Edit the button shadows: color, opacity, offset, radius\n- Show, hide activity indicator inside the button\n\n## Requirements\n- Swift 5.0\n- iOS 11.0+\n\n## Getting started\n\n### Storyboard Setup\nDrag and drop `UIButton` into your Storyboard and set its class and module to `QBIndicatorButton`.\n\n\u003cimg alt=\"custom class\" src=\"https://github.com/sjc-bui/QBIndicatorButton/blob/master/Example/Screenshots/QBIndicatorButton-class.png\" width=\"450\"/\u003e\n\nCustomize your button by setting properties from the Interface Builder.\n\n\u003cimg alt=\"custom properties\" src=\"https://github.com/sjc-bui/QBIndicatorButton/blob/master/Example/Screenshots/QBIndicatorButton-properties.png\" width=\"450\"/\u003e\n\n### Code Setup\n```swift\nvar loadingButton: QBIndicatorButton!\nloadingButton = QBIndicatorButton(text: \"Tap me\",\n                              textColor: UIColor.white,\n                              font: UIFont.systemFont(ofSize: 18, weight: .semibold),\n                              backgroundColor: .systemBlue,\n                              cornerRadius: 4.0)\n```\nButton touch closure.\n```swift\nloadingButton.touch({ btn in\n    // do stuff here\n    btn.start()\n}, for: .touchUpInside)\n```\n\nShow loading indicator.\n```swift\nloadingButton.start()\n// or\nloadingButton.start {\n    // do something when start\n    print(\"starting...\")\n}\n```\n\nHide loading indicator.\n```swift\nloadingButton.stop()\n// or\nloadingButton.stop {\n    // do something when stop\n    print(\"stopping...\")\n}\n```\n\n## Appearance\nSupported appearance properties are:\n\n| Property | Type | Description | Default value |\n| --- | --- | --- | --- |\n| `animatedScale` | `CGFloat` | Animated scale | `1.0` |\n| `animatedScaleDuration` | `Double` | Animated scale duration | `0.2` |\n| `borderColor` | `UIColor` | Border color | `UIColor.clear` |\n| `borderWidth` | `CGFloat` | Border width | `0.0` |\n| `cornerRadius` | `CGFloat` | Corner radius | `4.0` |\n| `shadowColor` | `UIColor` | The color of the layer's shadow | `UIColor.clear` |\n| `shadowOffset` | `CGSize` | The offset of the layer's shadow | `.zero` |\n| `shadowOpacity` | `Float` | The opacity of the layer's shadow | `0.0` |\n| `shadowRadius` | `CGFloat` | The blur radius of the layer's shadow | `0.0` |\n| `gradientEnabled` | `Bool` | Enable gradient background color | `false` |\n| `gradientStartColor` | `UIColor` | Start of color gradient | `UIColor.clear` |\n| `gradientEndColor` | `UIColor` | End of color gradient | `UIColor.clear` |\n| `gradientDirection` | `Int` | Direction of color gradient `0~7` | `1` |\n| `activityIndicatorPosition` | `Int` | Position of activity indicator `0~2` | `1` |\n| `titleFadeDuration` | `Double` | Button title fade animated duration | `0.3` |\n| `indicatorRotateDuration` (v0.1.7) | `CFTimeInterval` | The activity indicator rotate duration | `1.0` |\n| `indicatorStrokeColor` (v0.1.7) | `UIColor` | Custom color of activity indicator | `.white` |\n| `indicatorStrokeWidth` (v0.1.7) | `CGFloat` | Stroke width of activity indicator | `3.0` |\n\n`QBIndicatorButton` also supported round every single corner of the button.\n```swift\n// round topLeft and topRight corner only\nloadingButton.roundCorners(corners: [.topLeft, .topRight], radius: 20)\n// or\n// round all corner\nloadingButton.roundCorners(corners: [.allCorners], radius: 20)\n```\n\nPredefined positions of activity indicator.\n```swift\npublic enum IndicatorPosition: Int {\n    case left   = 0\n    case center = 1\n    case right  = 2\n}\n```\n\nPredefined directions for color gradient.\n```swift\npublic enum GradientDirection: Int {\n    case toTop         = 0\n    case toRight       = 1\n    case toBottom      = 2\n    case toLeft        = 3\n    case toTopRight    = 4\n    case toTopLeft     = 5\n    case toBottomRight = 6\n    case toBottomLeft  = 7\n}\n```\n\n## Installation\n\nQBIndicatorButton is available through [CocoaPods](https://cocoapods.org). To install\nit, simply add the following line to your Podfile:\n\n```ruby\npod 'QBIndicatorButton'\n```\n\n## Contributing\n\n- If you **found a bug**, open an issue.\n- If you **have a feature request**, open an issue.\n- If you **need help**, open an issue.\n- If you **want to contribute**, submit a pull request.\n\n## MIT License\n\nQBIndicatorButton is available under the MIT license. See the LICENSE file for more info.\n\nMade with :heart: by [sjc-bui](https://github.com/sjc-bui).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsjc-bui%2FQBIndicatorButton","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsjc-bui%2FQBIndicatorButton","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsjc-bui%2FQBIndicatorButton/lists"}