{"id":2033,"url":"https://github.com/eddiekaiger/SwiftyAttributes","last_synced_at":"2025-08-06T14:32:59.653Z","repository":{"id":2557666,"uuid":"46214246","full_name":"eddiekaiger/SwiftyAttributes","owner":"eddiekaiger","description":"A Swifty API for attributed strings","archived":false,"fork":false,"pushed_at":"2024-01-02T00:06:00.000Z","size":254,"stargazers_count":1635,"open_issues_count":3,"forks_count":85,"subscribers_count":18,"default_branch":"master","last_synced_at":"2025-08-02T16:11:39.750Z","etag":null,"topics":["carthage","cocoa","cocoapods","ios","macos","nsattributedstring","swift","swifty-api","tvos","watchos"],"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/eddiekaiger.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,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2015-11-15T11:08:38.000Z","updated_at":"2025-06-30T20:30:51.000Z","dependencies_parsed_at":"2024-01-02T01:44:24.444Z","dependency_job_id":null,"html_url":"https://github.com/eddiekaiger/SwiftyAttributes","commit_stats":{"total_commits":151,"total_committers":10,"mean_commits":15.1,"dds":0.2450331125827815,"last_synced_commit":"1ae513a1617309455a115c3fc2d558f744b43788"},"previous_names":[],"tags_count":20,"template":false,"template_full_name":null,"purl":"pkg:github/eddiekaiger/SwiftyAttributes","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eddiekaiger%2FSwiftyAttributes","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eddiekaiger%2FSwiftyAttributes/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eddiekaiger%2FSwiftyAttributes/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eddiekaiger%2FSwiftyAttributes/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/eddiekaiger","download_url":"https://codeload.github.com/eddiekaiger/SwiftyAttributes/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eddiekaiger%2FSwiftyAttributes/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":269021707,"owners_count":24346258,"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","status":"online","status_checked_at":"2025-08-06T02:00:09.910Z","response_time":99,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["carthage","cocoa","cocoapods","ios","macos","nsattributedstring","swift","swifty-api","tvos","watchos"],"created_at":"2024-01-05T20:16:01.734Z","updated_at":"2025-08-06T14:32:59.385Z","avatar_url":"https://github.com/eddiekaiger.png","language":"Swift","readme":"# SwiftyAttributes\n\n#### *A Swifty API for attributed strings.*\n\n![Swift Version](https://img.shields.io/badge/swift-5-orange.svg?style=flat)\n![Swift Version](https://img.shields.io/badge/swift-4.2-orange.svg?style=flat)\n[![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage)\n[![CocoaPods Compatible](https://img.shields.io/cocoapods/v/SwiftyAttributes.svg)](https://img.shields.io/cocoapods/v/SwiftyAttributes.svg)\n[![Platform](https://img.shields.io/cocoapods/p/SwiftyAttributes.svg?style=flat)](http://cocoapods.org/pods/SwiftyAttributes)\n[![Travis CI](https://travis-ci.org/eddiekaiger/SwiftyAttributes.svg?branch=master)](https://travis-ci.org/eddiekaiger/SwiftyAttributes.svg?branch=master)\n[![codecov.io](http://codecov.io/github/eddiekaiger/SwiftyAttributes/coverage.svg?branch=master)](http://codecov.io/github/eddiekaiger/SwiftyAttributes/coverage.svg?branch=master)\n\n---\n\nWith **SwiftyAttributes**, you can create attributed strings like so:\n\n````swift\nlet fancyString = \"Hello World!\".withTextColor(.blue).withUnderlineStyle(.styleSingle)\n````\n\nAlternatively, use the `Attribute` enum:\n````swift\nlet fancyString = \"Hello World!\".withAttributes([\n    .backgroundColor(.magenta),\n    .strokeColor(.orange),\n    .strokeWidth(1),\n    .baselineOffset(5.2)\n])\n````\n\nYou can also easily combine attributed strings using a plus sign:\n\n````swift\nlet fancyString = \"Hello\".withFont(.systemFont(ofSize: 12)) + \" World!\".withFont(.systemFont(ofSize: 18))\n````\n\n**SwiftyAttributes** has support for *every* attribute available in Cocoa and Cocoa Touch.\n\n# Requirements\n\n* iOS 8.0+, macOS 10.11+, watchOS 2.0+, tvOS 9.0+\n* Swift 4.2+\n* Xcode 10.0+\n\n# Installation\n\n### Swift Package Manager\n\n```swift\ndependencies: [\n    .package(url: \"https://github.com/eddiekaiger/SwiftyAttributes.git\", from: \"5.3.0\")\n]\n```\n\n### With CocoaPods\n\n`pod 'SwiftyAttributes'`\n\n### With Carthage\n\n`github \"eddiekaiger/SwiftyAttributes\"`\n\n# Usage\n\nInitializing attributed strings in `SwiftyAttributes` can be done several ways:\n\n- Using the `with[Attribute]` extensions:\n    ````swift\n    \"Hello World\".withUnderlineColor(.red).withUnderlineStyle(.styleDouble)\n    ````\n\n- Using the `Attribute` enum extensions:\n    ````swift\n    \"Hello World\".withAttributes([.underlineColor(.red), .underlineStyle(.styleDouble)])\n    ````\n\n- Using the `Attribute` enum in an initializer:\n    ````swift\n    NSAttributedString(string: \"Hello World\", swiftyAttributes: [.kern(5), .backgroundColor(.gray)])\n    ````\n    \nYou can retrieve the attribute at a specific location using the built-in `NSAttributedString.Key` enum:\n````swift\nlet attr: Attribute? = myAttributedString.swiftyAttribute(.shadow, at: 5)\n````\n\nSeveral API methods are provided to use these new enums as well as Swift's `Range` type instead of `NSRange`. Some of the method signatures include:\n\n````swift\nextension NSMutableAttributedString {\n    func addAttributes(_ attributes: [Attribute], range: Range\u003cInt\u003e)\n    func addAttributes(_ attributes: [Attribute], range: NSRange)\n    func setAttributes(_ attributes: [Attribute], range: Range\u003cInt\u003e)\n    func setAttributes(_ attributes: [Attribute], range: NSRange)\n    func replaceCharacters(in range: Range\u003cInt\u003e, with str: String)\n    func replaceCharacters(in range: Range\u003cInt\u003e, with attrString: NSAttributedString)\n    func deleteCharacters(in range: Range\u003cInt\u003e)\n    func removeAttribute(_ name: NSAttributedStringKey, range: Range\u003cInt\u003e)\n}\n\nextension NSAttributedString {\n    convenience init(string str: String, swiftyAttributes: [Attribute])\n    func withAttributes(_ attributes: [Attribute]) -\u003e NSMutableAttributedString\n    func withAttribute(_ attribute: Attribute) -\u003e NSMutableAttributedString\n    func attributedSubstring(from range: Range\u003cInt\u003e) -\u003e NSAttributedString\n    func swiftyAttribute(_ attrName: NSAttributedStringKey, at location: Int, effectiveRange range: NSRangePointer? = nil) -\u003e Attribute?\n    func swiftyAttributes(in range: Range\u003cInt\u003e, options: NSAttributedString.EnumerationOptions = []) -\u003e [([Attribute], Range\u003cInt\u003e)]\n    func enumerateSwiftyAttributes(in enumerationRange: Range\u003cInt\u003e, options: NSAttributedString.EnumerationOptions = [], using block: (_ attrs: [Attribute], _ range: Range\u003cInt\u003e, _ stop: UnsafeMutablePointer\u003cObjCBool\u003e) -\u003e Void)\n    func enumerateSwiftyAttribute(_ attrName: NSAttributedStringKey, in enumerationRange: Range\u003cInt\u003e, options: NSAttributedString.EnumerationOptions = [], using block: (_ value: Any?, _ range: Range\u003cInt\u003e, _ stop: UnsafeMutablePointer\u003cObjCBool\u003e) -\u003e Void)\n}\n\nextension String {\n    var attributedString: NSMutableAttributedString\n    func withAttributes(_ attributes: [Attribute]) -\u003e NSMutableAttributedString\n    func withAttribute(_ attribute: Attribute) -\u003e NSMutableAttributedString\n}\n\n// ... and more!\n\n````\n\n# Support\n\nFor questions, support, and suggestions, please open up an issue.\n\n# License\n\n**SwiftyAttributes** is available under the MIT license. See the LICENSE file for more info.\n","funding_links":[],"categories":["Libs","Swift","Text","UI","Text [🔝](#readme)"],"sub_categories":["Text","Other free courses","Layout","Other Testing","Keychain"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feddiekaiger%2FSwiftyAttributes","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Feddiekaiger%2FSwiftyAttributes","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feddiekaiger%2FSwiftyAttributes/lists"}