{"id":15038720,"url":"https://github.com/dimpiax/styledecorator","last_synced_at":"2025-04-10T00:02:15.616Z","repository":{"id":62456171,"uuid":"77305185","full_name":"dimpiax/StyleDecorator","owner":"dimpiax","description":"Easy string decoration with styles","archived":false,"fork":false,"pushed_at":"2019-11-10T17:36:29.000Z","size":475,"stargazers_count":15,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-10T00:01:04.505Z","etag":null,"topics":["attributedstring","cocoapods","decorator","ios","library","style","swift-3"],"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/dimpiax.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":"2016-12-25T00:47:42.000Z","updated_at":"2021-11-04T11:25:17.000Z","dependencies_parsed_at":"2022-11-01T23:03:46.846Z","dependency_job_id":null,"html_url":"https://github.com/dimpiax/StyleDecorator","commit_stats":null,"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dimpiax%2FStyleDecorator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dimpiax%2FStyleDecorator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dimpiax%2FStyleDecorator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dimpiax%2FStyleDecorator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dimpiax","download_url":"https://codeload.github.com/dimpiax/StyleDecorator/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248131322,"owners_count":21052819,"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":["attributedstring","cocoapods","decorator","ios","library","style","swift-3"],"created_at":"2024-09-24T20:39:51.654Z","updated_at":"2025-04-10T00:02:15.571Z","avatar_url":"https://github.com/dimpiax.png","language":"Swift","readme":"# StyleDecorator\n\n[![Language](https://img.shields.io/badge/swift-5.0-fec42e.svg)](https://swift.org/blog/swift-5-0-released/)\n[![Version](https://img.shields.io/cocoapods/v/StyleDecorator.svg?style=flat)](http://cocoapods.org/pods/StyleDecorator)\n[![License](https://img.shields.io/cocoapods/l/StyleDecorator.svg?style=flat)](http://cocoapods.org/pods/StyleDecorator)\n[![Platform](https://img.shields.io/cocoapods/p/StyleDecorator.svg?style=flat)](http://cocoapods.org/pods/StyleDecorator)\n\nDesign string simply by linking attributes.\n\n\u003cimg src=thumbnail.png width=25% height=25% /\u003e\n\n## Example\n\nCreate `Decorator` with specific `Style` and link it at the end of needed string or wrap for styling:\n\n```swift\n\"Style\" + d1 + \"Decorator\" + d2 + \"!\"\n// or\nd1.wrap(\"Style\") + d2.wrap(\"Decorator\") + \"!\"\n```\n\nExample:\n```swift\nlet a = Decorator(style: Style().foregroundColor(.black).kerning(-0.5).backgroundColor(.darkGray))\nlet b = Decorator(style: Style().foregroundColor(.white).backgroundColor(.black))\nlet c = Decorator(style: Style().foregroundColor(.gray).alignment(.right))\n\n// You can write in syntax you prefer\nlet decoratedText = \"Bold\" + a + \"Heavy\" + b + \"Black\" + c\nlabel.attributedText = NSAttributedString(decorator: decoratedText)\n\n// or\nlet a1 = a.wrap, b1 = b.wrap, c1 = c.wrap\nlet decoratedText2 = a1(\"Bold\") + b1(\"Heavy\") + c1(\"Black\")\nlabel.attributedText = NSAttributedString(decorator: decoratedText2)\n```\n\nString can be designed dynamically:\n```swift\n// check Example for detailed code, where created 'd', 'e', 'f' etc\n\nlet titleText = \"! \" + (\"Bold\" + b + \"Heavy\" + c + \"Black\" + d)\nlet decoratedText = \"Decorate attributed string simply\" + a + \"\\n\\n\" + titleText + \"\\n\\n\" + \"Right\" + e + \"\\n\" + \"below black rect with red line\" + f + \"\\n\\n\\nwith default attributes\"\n\nlet defaultAttributes = Style()\n    .font(UIFont.systemFont(ofSize: 15, weight: UIFontWeightBlack))\n    .alignment(.center)\n    .attributes\n\nlabel.attributedText = NSAttributedString(decorator: decoratedText, attributes: defaultAttributes)\n```\n\n## Requirements\n\n### Updated to Swift 5\n#### Supports SPM\n\n###### For Swift 4 version use [v.0.4.2](../../releases/tag/0.4.2)\n###### For Swift 3.1 version use [v.0.3.0](../../releases/tag/0.3.0)\n\n## Installation\n\nStyleDecorator is available through [CocoaPods](http://cocoapods.org). To install\nit, simply add the following line to your Podfile:\n\n```ruby\npod \"StyleDecorator\"\n```\n\n## Author\n\nDmytro Pylypenko, dimpiax@gmail.com\n\n## License\n\nStyleDecorator is available under the MIT license. See the LICENSE file for more info.\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdimpiax%2Fstyledecorator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdimpiax%2Fstyledecorator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdimpiax%2Fstyledecorator/lists"}