{"id":19174324,"url":"https://github.com/vectorform/texty","last_synced_at":"2026-03-08T16:05:28.179Z","repository":{"id":56924113,"uuid":"88896824","full_name":"vectorform/Texty","owner":"vectorform","description":"Enjoy clean and easy text styling using a simplified and structured syntax.","archived":false,"fork":false,"pushed_at":"2022-01-25T17:33:26.000Z","size":180,"stargazers_count":25,"open_issues_count":1,"forks_count":1,"subscribers_count":4,"default_branch":"develop","last_synced_at":"2025-04-17T14:20:54.725Z","etag":null,"topics":["attributedstring","carthage","cocoapods","ios","swift4-2","uilabel"],"latest_commit_sha":null,"homepage":"https://www.vectorform.com/","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/vectorform.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-04-20T18:17:38.000Z","updated_at":"2022-01-20T21:53:39.000Z","dependencies_parsed_at":"2022-08-21T05:20:54.409Z","dependency_job_id":null,"html_url":"https://github.com/vectorform/Texty","commit_stats":null,"previous_names":[],"tags_count":14,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vectorform%2FTexty","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vectorform%2FTexty/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vectorform%2FTexty/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vectorform%2FTexty/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/vectorform","download_url":"https://codeload.github.com/vectorform/Texty/tar.gz/refs/heads/develop","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252931785,"owners_count":21827163,"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","carthage","cocoapods","ios","swift4-2","uilabel"],"created_at":"2024-11-09T10:17:16.617Z","updated_at":"2026-03-08T16:05:28.133Z","avatar_url":"https://github.com/vectorform.png","language":"Swift","readme":"[![Build Status](https://travis-ci.org/vectorform/Texty.svg)](https://travis-ci.org/vectorform/Texty)\n[![Platform](https://img.shields.io/cocoapods/p/Texty.svg?style=flat)](http://cocoadocs.org/docsets/Texty)\n[![CocoaPods Compatible](https://img.shields.io/cocoapods/v/Texty.svg)](https://img.shields.io/cocoapods/v/Texty.svg)\n[![Carthage Compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage)\n\n# Texty\nTexty's goal is to make styling text clean and easy. This is accomplished using things like style containers, styled label initializers, and string styling via XML-like tags.\n\nCreated and maintained by Vectorform, LLC.\n\n\n## Requirements:\n- iOS 13.0+\n- Xcode 10.0+\n- Swift 5.0+\n\n\n## Installation\n### CocoaPods\n[CocoaPods](http://cocoapods.org) is a dependency manager for Cocoa projects. You can install it with the following command:\n```bash\n$ gem install cocoapods\n```\n\n\u003e CocoaPods 1.0.0+ is required to build Texty.\n\nTo integrate Texty into your Xcode project using CocoaPods, specify it in your `Podfile`:\n\n```ruby\nsource 'https://github.com/CocoaPods/Specs.git'\nplatform :ios, '10.0'\nuse_frameworks!\n\ntarget '\u003cYour Target Name\u003e' do\n    pod 'Texty', '~\u003e 0.2.6'\nend\n```\n\nThen, run the following command:\n\n```bash\n$ pod install\n```\n\n### Carthage\n[Carthage](https://github.com/Carthage/Carthage) is a decentralized dependency manager that builds your dependencies and provides you with binary frameworks.\n\nYou can install Carthage with [Homebrew](http://brew.sh/) using the following command:\n```bash\n$ brew update\n$ brew install carthage\n```\n\nTo integrate Texty into your Xcode project using Carthage, specify it in your `Cartfile`:\n```ogdl\ngithub \"Vectorform/Texty\" ~\u003e 0.2.7\n```\n\nRun `carthage update` to build the framework and drag the built `Texty.framework` into your Xcode project.\n\n\n### Manually\nIf you prefer not to use any of the listed dependency managers, you can integrate Texty into your project manually.\n\n\n---\n\n\n## Usage\n### Creating styles\nThe TextStyle class was designed to be created once and reused across your entire application. If you need to manipulate a TextStyle without affecting the original, you'll need to use the copy initializer `UITextStyle(with: TextStyle)`\n```swift\n/// Create static references to reusable styles\nstruct Style {\n    static let Header1: TextStyle = TextStyle(attributes: [.foregroundColor : UIColor.black, .font : UIFont.boldSystemFont(ofSize: 24.0)])\n\n    static let Header2: TextStyle = TextStyle(attributes: [.foregroundColor : UIColor.black, .font : UIFont.boldSystemFont(ofSize: 20.0)])\n\n    static let Normal: TextStyle = TextStyle(attributes: [.foregroundColor : UIColor.black, .font : UIFont.systemFont(ofSize: 17.0)])\n\n    static let Underline: TextStyle = TextStyle(attributes: [TextAttribute.underlineStyle : NSUnderlineStyle.styleSingle])\n}\n```\n```swift\n/// Reuse your defined styles across your entire application\nclass ViewController: UIViewController {\n    private let headerLabel: TextyLabel = TextyLabel(style: Style.Header1)\n    private let textLabel: TextyLabel = TextyLabel(style: Style.Normal)\n}\n```\n\n\n### Available attributes\n| TextAttribute      | Expected Type     | Native Equivalent                        |\n|--------------------|-------------------|------------------------------------------|\n| attachment         | NSTextAttachment  | NSAttributedStringKey.attachment         |\n| backgroundColor    | UIColor           | NSAttributedStringKey.backgroundColor    |\n| baselineOffset     | NSNumber          | NSAttributedStringKey.baselineOffset     |\n| expansion          | NSNumber          | NSAttributedStringKey.expansion          |\n| font               | UIFont            | NSAttributedStringKey.font               |\n| foregroundColor    | UIColor           | NSAttributedStringKey.foregroundColor    |\n| kern               | NSNumber          | NSAttributedStringKey.kern               |\n| ligature           | NSNumber          | NSAttributedStringKey.ligature           |\n| link               | NSURL or NSString | NSAttributedStringKey.link               |\n| obliqueness        | NSNumber          | NSAttributedStringKey.obliqueness        |\n| paragraphStyle     | NSParagraphStyle  | NSAttributedStringKey.paragraphStyle     |\n| shadow             | NSShadow          | NSAttributedStringKey.shadow             |\n| strikethroughColor | UIColor           | NSAttributedStringKey.strikethroughColor |\n| strikethroughStyle | NSNumber          | NSAttributedStringKey.strikethroughStyle |\n| strokeColor        | UIColor           | NSAttributedStringKey.strokeColor        |\n| strokeWidth        | NSNumber          | NSAttributedStringKey.strokeWidth        |\n| textEffect         | NSString          | NSAttributedStringKey.textEffect         |\n| underlineColor     | UIColor           | NSAttributedStringKey.underlineColor     |\n| underlineStyle     | NSNumber          | NSAttributedStringKey.underlineStyle     |\n| verticalGlyphForm  | NSNumber          | NSAttributedStringKey.verticalGlyphForm  |\n| writingDirection   | Array\\\u003cNSNumber\\\u003e | NSAttributedStringKey.writingDirection   |\n\nMore information about each attribute can be found in Apple's [documentation](https://developer.apple.com/documentation/foundation/nsattributedstringkey).\n\n\n### TextyLabel\nTextyLabel is a subclass of UILabel created specifically to work with TextStyle objects. The core power of TextyLabel comes from its initializer. TextyLabel will create a copy of the TextStyle object.\n```swift\nlet titleLabel: TextyLabel = TextyLabel(style: Style.Header1)\n```\nYou can manipulate or replace the style later using the `style` property.\n\nBe careful when subclassing TextyLabel as some properties are overriden to be referenced from the associated style object rather than their native locations.\n\nSubclassing TextyLabel and overriding one of these properties without calling the super class ***will*** result in undefined behavior.\n\n| Property      | Overriden Target                   |\n|---------------|------------------------------------|\n| font          | style.font                         |\n| lineBreakMode | style.paragraphStyle.lineBreakMode |\n| text          | attributedText                     |\n| textAlignment | style.paragraphStyle.alignment     |\n| textColor     | style.foregroundColor              |\n\n### TextyButton\nTextyButton is a subclass of UIButton created specifically to work with TextStyle objects. TextyButton can be initialized in the same way as TextyLabel. Internally this will be used as the style for all button states. TextyButton will create a copy of the TextStyle object.\n```swift\nlet button: TextyButton = TextyButton(style: Style.Header1)\n```\nYou can manipulate or replace the styles later using the following functions:\n```swift\nstyle(for state: UIControlState)\nsetStyle(_ style: TextStyle, for state: UIControlState)\n```\n\nBe careful when subclassing TextyButton as some properties are overriden to be referenced from the associated style object rather than their native locations.\n\nSubclassing TextyButton and overriding one of these properties without calling the super class ***will*** result in undefined behavior.\n\n| Function      | Overriden Target                   |\n|---------------|------------------------------------|\n| setTitle(_ title: String?, for state: UIControlState) | setAttributedTitle(_ title: NSAttributedString?, for state: UIControlState) |\n| title(for state: UIControlState)          | attributedTitle(for: state)                     |\n| setTitleColor(_ color: UIColor?, for state: UIControlState) | style(for: state).foregroundColor\n| titleColor(for state: UIControlState)     | style(for: state).foregroundColor              |\n| setTitleShadowColor(_ color: UIColor?, for state: UIControlState) | style(for: state).shadow |\n| titleShadowColor(for state: UIControlState)| style(for: state).shadow |\n\n### TextyTextView\nTextyTextView is a subclass of UITextView created specifically to work with TextStyle objects. The core power of TextyTextView comes from its initializer. TextyTextView will create a copy of the TextStyle object.\n```swift\nlet titleLabel: TextyLabel = TextyLabel(style: Style.Header1)\n```\n**TextyTextView does not currently support editing text** so you should have `isEditable` set to `false`.\n\nYou can manipulate or replace the style later using the `style` property.\n\nBe careful when subclassing TextyTextView as some properties are overriden to be referenced from the associated style object rather than their native locations.\n\nSubclassing TextyTextView and overriding one of these properties without calling the super class ***will*** result in undefined behavior.\n\n| Property      | Overriden Target                   |\n|---------------|------------------------------------|\n| font          | style.font                         |\n| lineBreakMode | style.paragraphStyle.lineBreakMode |\n| text          | attributedText                     |\n| textAlignment | style.paragraphStyle.alignment     |\n| textColor     | style.foregroundColor              |\n\n### Styling text via tags\nTexty provides the ability to style parts of a string using XML-like tags within the string.\n```swift\nlet titleLabel: TextyLabel = TextyLabel(style: Style.Header1)\nself.titleLabel.style.setStyle(Style.Underline, forTag: \"underline\")\nself.titleLabel.text = \"This is a \u003cunderline\u003eTextyLabel\u003c/underline\u003e\"\n```\n\nYou can also forego creating a TextStyle and use an attribute dictionary instead.\n```swift\nlet titleLabel: TextyLabel = TextyLabel(style: Style.Header1)\nself.titleLabel.style.setAttributes([TextAttribute.underlineStyle : NSUnderlineStyle.styleSingle.rawValue], forTag: \"underline\")\nself.titleLabel.text = \"This is a \u003cunderline\u003eTextyLabel\u003c/underline\u003e\"\n```\n\nUnlike XML, tags do not have to be balanced. For example, the following string is valid (given that the bold and italic tags are defined):\n\n```This is \u003citalic\u003ean example \u003cbold\u003estring used\u003c/italic\u003e for demonstration\u003c/bold\u003e purposes.```\n\n**It is important that your closing tags have the forward slash at the beginning and not the end.**\n\n| Good      | Bad       |\n|-----------|-----------|\n| \\\u003c/bold\\\u003e | \\\u003cbold/\\\u003e |\n\nForward slashes at the end of a tag will cause the tag to be detected as a *short tag*, which will have a use in the future, but currently offers nothing.\n\n**There is currently no way to escape tags within a string - all tags will be stripped during the styling process.**\n\n\n---\n\n\n## Credits\n[Igor Efremov](https://github.com/igorefremov), [igor@efremov.io](mailto:igor@efremov.io)\n\n[Jeff Meador](https://github.com/jeffMeador), [jmeador@vectorform.com](mailto:jmeador@vectorform.com)\n\n## License\nTexty is available under the [BSD-3-Clause](https://opensource.org/licenses/BSD-3-Clause) License. See the [LICENSE](LICENSE) file for more info.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvectorform%2Ftexty","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvectorform%2Ftexty","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvectorform%2Ftexty/lists"}