{"id":2506,"url":"https://github.com/IdleHandsApps/DesignableButton","last_synced_at":"2025-08-03T00:31:51.735Z","repository":{"id":56914950,"uuid":"81764186","full_name":"IdleHandsApps/DesignableButton","owner":"IdleHandsApps","description":"A Custom UIButton with Centralised Styling and common styles available in Interface Builder","archived":false,"fork":false,"pushed_at":"2019-07-01T03:37:19.000Z","size":12740,"stargazers_count":92,"open_issues_count":1,"forks_count":11,"subscribers_count":6,"default_branch":"master","last_synced_at":"2024-11-28T02:35:32.671Z","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/IdleHandsApps.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":"2017-02-12T22:57:34.000Z","updated_at":"2024-05-17T19:09:12.000Z","dependencies_parsed_at":"2022-08-20T20:50:38.804Z","dependency_job_id":null,"html_url":"https://github.com/IdleHandsApps/DesignableButton","commit_stats":null,"previous_names":[],"tags_count":17,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/IdleHandsApps%2FDesignableButton","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/IdleHandsApps%2FDesignableButton/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/IdleHandsApps%2FDesignableButton/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/IdleHandsApps%2FDesignableButton/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/IdleHandsApps","download_url":"https://codeload.github.com/IdleHandsApps/DesignableButton/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":228510713,"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.433Z","updated_at":"2024-12-06T18:30:31.095Z","avatar_url":"https://github.com/IdleHandsApps.png","language":"Swift","readme":"\u003cp align=\"center\"\u003e\n  \u003cimg alt=\"DesignableButton\" src=\"https://github.com/IdleHandsApps/DesignableButton/blob/files/Logo-60.png\" /\u003e\n\u003c/p\u003e\n\nDesignableButton [![Language: Swift 4.0](https://img.shields.io/badge/Swift-4.0-orange.svg)](https://swift.org)\n------------------------------\n\n![alt demo](https://github.com/IdleHandsApps/DesignableButton/blob/files/DesButGif.gif)\n\nDesignableButton is a UIButton subclass that uses a centralised and reusable styling. In InterfaceBuilder, drag and drop a DesignableButton, choose your style and its applied instantly in InterfaceBuilder\n\n## Features\n\n* One centralised class to define you main button styles so they can be reused\n* Different styles for different button states: Normal/Selected/Disabled\n* The centralised styles can be set in IB (no more IBOutlets needed for programatical styling)\n* View the style in IB in realtime. Even changing button to selected state will update IB\n* Individual buttons can override their centralised styles in IB\n* Rounded corners and borders are easy with DesignableButton\n* Buttons with an image above text are easy with DesignableButton\n\n## How to install\n\nAdd this to your CocoaPods Podfile. *Note the IH prefix*\n```\npod 'IHDesignableButton'\n```\n\n## How to use\n\nCreate an DesignableButton+Styles.swift extension file in your project\n```swift\nimport UIKit\nimport IHDesignableButton // if DesignableButton is in CocoaPod\nextension DesignableButton {\n    \n    override open func prepareForInterfaceBuilder() {\n        super.prepareForInterfaceBuilder()\n        \n        DesignableButton.setDesignableStyles(isInterfaceBuilder: true)\n    }\n    \n    static func setDesignableStyles(isInterfaceBuilder: Bool = false) {\n        \n        // example style\n        DesignableButton.setStyle(style: { (designableButton: DesignableButton) -\u003e Void in\n            if designableButton.isHighlighted || designableButton.isSelected {\n                // replace this with your style for selected/highlighted states\n                designableButton.setTitleColor(designableButton.customTextColor ?? UIColor.white, for: UIControlState())\n                designableButton.backgroundColor = designableButton.selectedColor ?? UIColor.red\n                designableButton.layer.borderColor = designableButton.selectedColor?.cgColor ?? UIColor.red.cgColor\n                designableButton.layer.borderWidth = designableButton.borderWidth ?? 0\n            } else if designableButton.isEnabled {\n                // replace this with your style for the normal state\n                designableButton.setTitleColor(designableButton.customTextColor ?? UIColor.white, for: UIControlState())\n                designableButton.backgroundColor = designableButton.defaultColor ?? UIColor.blue\n                designableButton.layer.borderColor = designableButton.defaultColor?.cgColor ?? UIColor.blue.cgColor\n                designableButton.layer.borderWidth = designableButton.borderWidth ?? 0\n            }\n            else {\n                // replace this with your style for the disabled state\n                designableButton.setTitleColor(designableButton.customTextColor ?? UIColor.lightGray, for: UIControlState())\n                designableButton.backgroundColor = designableButton.disabledColor ?? UIColor.lightGray()\n                designableButton.layer.borderColor = designableButton.borderColor?.cgColor ??  UIColor.gray.cgColor\n                designableButton.layer.borderWidth = designableButton.borderWidth ?? 1\n            }\n            \n            // replace this with your style for all states\n            designableButton.layer.cornerRadius = designableButton.cornerRadius ?? 12\n            \n            designableButton.setTitle(designableButton.titleLabel?.text, for: .normal)\n            \n        }, for: \"primary\") // this is the name/key of your style\n    }\n}\n```\n\nIn the ```setDesignableStyles()``` method you can call ```DesignableButton.setStyle()``` to create a new style. Most projects will only need a few button styles\n\nIn you AppDelegate's ```application(_ , didFinishLaunchingWithOptions()``` call ```DesignableButton.setDesignableStyles()```\n\nNow in Interface Builder, drag a UIButton onto a view\n\nChange the class to ```DesignableButton``` and the module to ```IHDesignableButton```\n\nChange the button type from ```System``` to ```Custom```\n\nSet the Button Style to \"primary\" or any other button style you're created\n\n\n## Half price for a limited time only :)\n\nA Codable extension to decode arrays and to catch \u0026 log all decoding failures\nhttps://github.com/IdleHandsApps/SafeDecoder\n\nAn elegant solution for keeping views visible when the keyboard is being shown https://github.com/IdleHandsApps/IHKeyboardAvoiding\n\nA fully automatic status bar overlay for No Internet Connection messages \nhttps://github.com/IdleHandsApps/StatusBarOverlay\n\n## Author\n\n* Fraser Scott-Morrison (fraserscottmorrison@me.com)\n\nIt'd be great to hear about any cool apps that are using DesignableButton\n\n## License \n\nDistributed under the MIT License\n","funding_links":[],"categories":["UI"],"sub_categories":["Button","Other free courses"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FIdleHandsApps%2FDesignableButton","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FIdleHandsApps%2FDesignableButton","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FIdleHandsApps%2FDesignableButton/lists"}