{"id":16684960,"url":"https://github.com/tungvoduc/dtgradientbutton","last_synced_at":"2026-02-28T19:01:51.316Z","repository":{"id":56907940,"uuid":"129908289","full_name":"tungvoduc/DTGradientButton","owner":"tungvoduc","description":"Easy way to set gradient background to your buttons.","archived":false,"fork":false,"pushed_at":"2019-07-04T18:11:24.000Z","size":103,"stargazers_count":89,"open_issues_count":2,"forks_count":16,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-04-29T22:58:25.489Z","etag":null,"topics":["cocoapods","gradient","swift","swift-package-manager","swift4","swift5","uibutton","uibutton-extension","uikit","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/tungvoduc.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":"2018-04-17T13:24:36.000Z","updated_at":"2023-05-01T07:00:40.000Z","dependencies_parsed_at":"2022-08-21T03:50:19.896Z","dependency_job_id":null,"html_url":"https://github.com/tungvoduc/DTGradientButton","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tungvoduc%2FDTGradientButton","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tungvoduc%2FDTGradientButton/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tungvoduc%2FDTGradientButton/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tungvoduc%2FDTGradientButton/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tungvoduc","download_url":"https://codeload.github.com/tungvoduc/DTGradientButton/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243835942,"owners_count":20355611,"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":["cocoapods","gradient","swift","swift-package-manager","swift4","swift5","uibutton","uibutton-extension","uikit","xcode"],"created_at":"2024-10-12T14:45:38.445Z","updated_at":"2025-03-17T00:32:52.201Z","avatar_url":"https://github.com/tungvoduc.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"# DTGradientButton\n\n[![Version](https://img.shields.io/cocoapods/v/DTGradientButton.svg?style=flat)](http://cocoapods.org/pods/DTGradientButton)\n[![License](https://img.shields.io/cocoapods/l/DTGradientButton.svg?style=flat)](http://cocoapods.org/pods/DTGradientButton)\n[![Platform](https://img.shields.io/cocoapods/p/DTGradientButton.svg?style=flat)](http://cocoapods.org/pods/DTGradientButton)\n\n## Screenshot\n\u003cimg src=\"Screenshots/buttons.png\" width=\"400\"\u003e\n\u003cbr/\u003e\n\n## Example\nTo run the example project, clone the repo, and run `pod install` from the Example directory first.\n\n## Usage\nTo set gradient colors as background for a button, just use it as below:\n\n```swift\nlet colors = [UIColor(hex: \"FF8960\"), UIColor(hex: \"FF62A5\")]\nbutton.setGradientBackgroundColors(colors, direction: .toRight, for: .normal)\n```\n\nMethod ```setGradientBackgroundColors(_ colors:, direction:, for state:)``` is provided as an extended method of UIButton. For that reason, you can use it for any UIButton instance in your project. \n\nEight predefined directions are supported for the gradient.\n\n```swift\npublic enum DTImageGradientDirection {\n    case toLeft\n    case toRight\n    case toTop\n    case toBottom\n    case toBottomLeft\n    case toBottomRight\n    case toTopLeft\n    case toTopRight\n}\n```\n\nBesides setting gradient background for UIButton, you can take advantage of this library to create gradient image as below:\n\n```swift\nlet colors = [UIColor(hex: \"FF8960\"), UIColor(hex: \"FF62A5\")]\nlet image = UIImage(size: CGSize(width: 100, height: 100), direction: .toBottom, colors: colors)\n```\n\n## Requirements\n### iOS 8.0\n\n## Installation\n\n### CocoaPods\nAdd the following line to your Podfile:\n\n```ruby\npod 'DTGradientButton'\n```\n\n### Swift package manager\n`DTGradientButton ` is available for SPM from version `0.1.3`.\nAdd the following to the dependencies of your `Package.swift`:\n\n```swift\n.package(url: \"https://github.com/tungvoduc/DTGradientButton\", from: \"version\")\n```\n\n## Author\n\nTung Vo, tung98.dn@gmail.com\n\n## License\n\nDTGradientButton is available under the MIT license. See the LICENSE file for more info.\n\n## Feedbacks \u0026 requests\n- Open an issue if you find a bug, make a proposal or simply need some help.\n- You can also contact me via [email](mailto:tung98.dn@gmail.com).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftungvoduc%2Fdtgradientbutton","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftungvoduc%2Fdtgradientbutton","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftungvoduc%2Fdtgradientbutton/lists"}