{"id":2018,"url":"https://github.com/delba/TextAttributes","last_synced_at":"2025-08-06T14:32:57.304Z","repository":{"id":56924144,"uuid":"55705803","full_name":"delba/TextAttributes","owner":"delba","description":"An easier way to compose attributed strings","archived":false,"fork":false,"pushed_at":"2019-11-16T19:46:39.000Z","size":2695,"stargazers_count":2191,"open_issues_count":2,"forks_count":120,"subscribers_count":34,"default_branch":"master","last_synced_at":"2024-11-14T12:53:32.439Z","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/delba.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-04-07T15:25:50.000Z","updated_at":"2024-11-02T18:05:51.000Z","dependencies_parsed_at":"2022-08-21T05:20:43.869Z","dependency_job_id":null,"html_url":"https://github.com/delba/TextAttributes","commit_stats":null,"previous_names":[],"tags_count":15,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/delba%2FTextAttributes","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/delba%2FTextAttributes/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/delba%2FTextAttributes/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/delba%2FTextAttributes/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/delba","download_url":"https://codeload.github.com/delba/TextAttributes/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":228915455,"owners_count":17991408,"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:01.361Z","updated_at":"2024-12-09T15:30:48.693Z","avatar_url":"https://github.com/delba.png","language":"Swift","funding_links":[],"categories":["Libs","Swift","UI","Text","Text [🔝](#readme)"],"sub_categories":["Text","Layout","Other free courses","Other Testing","Keychain"],"readme":"\u003cp align=\"center\"\u003e\n  \u003cimg src=\"https://raw.githubusercontent.com/delba/TextAttributes/assets/TextAttributes@2x.png\"\u003e\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://travis-ci.org/delba/TextAttributes\"\u003e\u003cimg alt=\"Travis Status\" src=\"https://img.shields.io/travis/delba/TextAttributes.svg\"/\u003e\u003c/a\u003e\n  \u003ca href=\"https://img.shields.io/cocoapods/v/TextAttributes.svg\"\u003e\u003cimg alt=\"CocoaPods compatible\" src=\"https://img.shields.io/cocoapods/v/TextAttributes.svg\"/\u003e\u003c/a\u003e\n  \u003ca href=\"https://github.com/Carthage/Carthage\"\u003e\u003cimg alt=\"Carthage compatible\" src=\"https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat\"/\u003e\u003c/a\u003e\n  \u003ca href=\"https://img.shields.io/cocoapods/p/TextAttributes.svg\"\u003e\u003cimg alt=\"Platform\" src=\"https://img.shields.io/cocoapods/p/TextAttributes.svg\"/\u003e\u003c/a\u003e\n\u003c/p\u003e\n\n**TextAttributes** makes it easy to compose attributed strings.\n\n```swift\nlet attrs = TextAttributes()\n    .font(name: \"HelveticaNeue\", size: 16)\n    .foregroundColor(white: 0.2, alpha: 1)\n    .lineHeightMultiple(1.5)\n\nNSAttributedString(string: \"The quick brown fox jumps over the lazy dog\", attributes: attrs)\n```\n\n\u003cp align=\"center\"\u003e\n    \u003ca href=\"#features\"\u003eFeatures\u003c/a\u003e • \u003ca href=\"#usage\"\u003eUsage\u003c/a\u003e • \u003ca href=\"#demo\"\u003eDemo\u003c/a\u003e • \u003ca href=\"#references\"\u003eReferences\u003c/a\u003e • \u003ca href=\"#installation\"\u003eInstallation\u003c/a\u003e • \u003ca href=\"#license\"\u003eLicense\u003c/a\u003e\n\u003c/p\u003e\n\n## Features\n\n- [x] Strongly typed properties\n- [x] Chainable setter methods\n- [x] A direct access to the `NSParagraphStyle` properties\n- [x] Better autocompletion\n\n## Usage\n\n- **Get or set the `TextAttributes` properties:**\n\n```swift\nattrs.font = UIFont(name: \"HelveticaNeue\", size: 16)\nattrs.backgroundColor = .white\n```\n\n\u003e See [all the properties](#references)\n\n- **Method chaining:**\n\nThe `TextAttributes` methods return `Self` to allow method chaining:\n\n```swift\nattrs\n    .lineHeightMultiple(1.5)\n    .underlineStyle(.styleSingle)\n```\n\n\u003e See [all the methods](#references)\n\n- **The methods are also constructors:**\n\nThe following are equivalent:\n\n```swift\nattrs\n    .font(name: \"HelveticaNeue\", size: 16)\n    .foregroundColor(white: 0.2, alpha: 1)\n```\n\n```swift\nlet font  = UIFont(name: \"HelveticaNeue\", size: 16)\nlet color = UIColor(white: 0.2, alpha: 1)\n\nattrs\n    .font(font)\n    .foregroundColor(color)\n```\n\n- **Access the underlying dictionary:**\n\n```swift\nattrs.dictionary // Returns the attributes dictionary of type [NSAttributedString.Key: Any]\n```\n\n#### Third-party libraries:\n\n- [muukii/**TextAttributesUtil**](https://github.com/muukii/TextAttributesUtil) Quickly create NSAttributedString with TextAttributes\n\n## Demo\n\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"https://raw.githubusercontent.com/delba/TextAttributes/assets/demo.gif\" /\u003e\n  \u003cem\u003eLive updates with \u003ca href=\"https://github.com/johnno1962/injectionforxcode\" alt=\"Injection for Xcode\"\u003eInjection for Xcode\u003c/a\u003e\u003c/em\u003e\n\u003c/p\u003e\n\n## References\n\n### Attributes dictionary\n\n| Dictionary Key                      | `TextAttributes` Property | `TextAttributes` Method                                |\n| ----------------------------------- | ------------------------- | ------------------------------------------------------ |\n| `NSFontAttributeName`               | `font`                    | `font(name:size:)`                                     |\n|                                     |                           | `font(_:)`                                             |\n| `NSParagraphStyleAttributeName`     | `paragraphStyle`          | `paragraphStyle(_:)`                                   |\n| `NSForegroundColorAttributeName`    | `foregroundColor`         | `foregroundColor(_:)`                                  |\n|                                     |                           |  `foregroundColor(white:alpha:)`                       |\n|                                     |                           | `foregroundColor(hue:saturation:brightness:alpha:)`    |\n|                                     |                           | `foregroundColor(red:green:blue:alpha:)`               |\n|                                     |                           | `foregroundColor(patternImage:)`                       |\n| `NSBackgroundColorAttributeName`    | `backgroundColor`         | `backgroundColor(_:)`                                  |\n|                                     |                           | `backgroundColor(white:alpha:)`                        |\n|                                     |                           | `backgroundColor(hue:saturation:brightness:alpha:)`    |\n|                                     |                           | `backgroundColor(red:green:blue:alpha:)`               |\n|                                     |                           | `backgroundColor(patternImage:)`                       |\n| `NSLigatureAttributeName`           | `ligature`                | `ligature(_:)`                                         |\n| `NSKernAttributeName`               | `kern`                    | `kern(_:)`                                             |\n| `NSStrikethroughStyleAttributeName` | `strikethroughStyle`      | `strikethroughStyle(_:)`                               |\n| `NSStrikethroughColorAttributeName` | `strikethroughColor`      | `strikethroughColor(_:)`                               |\n|                                     |                           | `strikethroughColor(white:alpha:)`                     |\n|                                     |                           | `strikethroughColor(hue:saturation:brightness:alpha:)` |\n|                                     |                           | `strikethroughColor(red:green:blue:alpha:)`            |\n|                                     |                           | `strikethroughColor(patternImage:)`                    |\n| `NSUnderlineStyleAttributeName`     | `underlineStyle`          | `underlineStyle(_:)`                                   |\n| `NSUnderlineColorAttributeName`     | `underlineColor`          | `underlineColor(_:)`                                   |\n|                                     |                           | `underlineColor(white:alpha:)`                         |\n|                                     |                           | `underlineColor(hue:saturation:brightness:alpha:)`     |\n|                                     |                           | `underlineColor(red:green:blue:alpha:)`                |\n|                                     |                           | `underlineColor(patternImage:)`                        |\n| `NSStrokeWidthAttributeName`        | `strokeWidth`             | `strokeWidth(_:)`                                      |\n| `NSStrokeColorAttributeName`        | `strokeColor`             | `strokeColor(_:)`                                      |\n|                                     |                           | `strokeColor(white:alpha:)`                            |\n|                                     |                           | `strokeColor(hue:saturation:brightness:alpha:)`        |\n|                                     |                           | `strokeColor(red:green:blue:alpha:)`                   |\n|                                     |                           | `strokeColor(patternImage:)`                           |\n| `NSShadowAttributeName`             | `shadow`                  | `shadow(_:)`                                           |\n|                                     |                           | `shadow(color:offset:blurRadius:)`                     |\n| `NSTextEffectAttributeName`         | `textEffect`              | `textEffect(_:)`                                       |\n| `NSAttachmentAttributeName`         | `attachment`              | `attachment(_:)`                                       |\n| `NSLinkAttributeName`               | `link`                    | `link(_:)`                                             |\n|                                     |                           | `link(string:)`                                        |\n|                                     |                           | `link(string:relativeToURL:)`                          |\n| `NSBaselineOffsetAttributeName`     | `baselineOffset`          | `baselineOffset(_:)`                                   |\n| `NSObliquenessAttributeName`        | `obliqueness`             | `obliqueness(_:)`                                      |\n| `NSExpansionAttributeName`          | `expansion`               | `expansion(_:)`                                        |\n| `NSVerticalGlyphFormAttributeName`  | `verticalGlyphForm`       | `verticalGlyphForm(_:)`                                |\n\n### Paragraph style\n\n| `NSMutableParagraphStyle` Property | `TextAttributes` Property | `TextAttributes` Method      |\n| ---------------------------------- | ------------------------- | ---------------------------- |\n| `alignment`                        | `alignment`               | `alignment(_:)`              |\n| `firstLineHeadIndent`              | `firstLineHeadIndent`     | `firstLineHeadIndent(_:)`    |\n| `headIndent`                       | `headIndent`              | `headIndent(_:)`             |\n| `tailIndent`                       | `tailIndent`              | `tailIndent(_:)`             |\n| `lineBreakMode`                    | `lineBreakMode`           | `lineBreakMode(_:)`          |\n| `maximumLineHeight`                | `maximumLineHeight`       | `maximumLineHeight(_:)`      |\n| `lineSpacing`                      | `lineSpacing`             | `lineSpacing(_:)`            |\n| `paragraphSpacing`                 | `paragraphSpacing`        | `paragraphSpacing(_:)`       |\n| `paragraphSpacingBefore`           | `paragraphSpacingBefore`  | `paragraphSpacingBefore(_:)` |\n| `baseWritingDirection`             | `baseWritingDirection`    | `baseWritingDirection(_:)`   |\n| `lineHeightMultiple`               | `lineHeightMultiple`      | `lineHeightMultiple(_:)`     |\n\n## Installation\n\n### Carthage\n\n[Carthage](https://github.com/Carthage/Carthage) is a decentralized dependency manager that automates the process of adding frameworks to your Cocoa application.\n\nYou can install Carthage with [Homebrew](http://brew.sh/) using the following command:\n\n```bash\n$ brew update\n$ brew install carthage\n```\n\nTo integrate TextAttributes into your Xcode project using Carthage, specify it in your `Cartfile`:\n\n```ogdl\ngithub \"delba/TextAttributes\"\n```\n\n### Cocoapods\n\n[CocoaPods](http://cocoapods.org) is a dependency manager for Cocoa projects.\n\nYou can install it with the following command:\n\n```bash\n$ gem install cocoapods\n```\n\nTo integrate TextAttributes into your Xcode project using CocoaPods, specify it in your `Podfile`:\n\n```ruby\nuse_frameworks!\n\npod 'TextAttributes'\n```\n\n## License\n\nCopyright (c) 2016-2019 Damien (http://delba.io)\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdelba%2FTextAttributes","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdelba%2FTextAttributes","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdelba%2FTextAttributes/lists"}