{"id":2581,"url":"https://github.com/TTTAttributedLabel/TTTAttributedLabel","last_synced_at":"2025-08-03T00:31:57.640Z","repository":{"id":38359484,"uuid":"1713774","full_name":"TTTAttributedLabel/TTTAttributedLabel","owner":"TTTAttributedLabel","description":"A drop-in replacement for UILabel that supports attributes, data detectors, links, and more","archived":false,"fork":false,"pushed_at":"2024-06-24T02:50:08.000Z","size":1653,"stargazers_count":8748,"open_issues_count":175,"forks_count":1698,"subscribers_count":211,"default_branch":"master","last_synced_at":"2025-07-27T06:38:22.312Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Objective-C","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/TTTAttributedLabel.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","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,"publiccode":null,"codemeta":null}},"created_at":"2011-05-06T23:37:12.000Z","updated_at":"2025-07-21T07:25:26.000Z","dependencies_parsed_at":"2024-01-02T21:15:15.629Z","dependency_job_id":"dd9df922-955b-4cc3-8990-48c55a44b617","html_url":"https://github.com/TTTAttributedLabel/TTTAttributedLabel","commit_stats":{"total_commits":544,"total_committers":114,"mean_commits":4.771929824561403,"dds":0.5827205882352942,"last_synced_commit":"e73ed542ee311873ba501aba087f4126d4cd864d"},"previous_names":[],"tags_count":39,"template":false,"template_full_name":null,"purl":"pkg:github/TTTAttributedLabel/TTTAttributedLabel","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TTTAttributedLabel%2FTTTAttributedLabel","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TTTAttributedLabel%2FTTTAttributedLabel/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TTTAttributedLabel%2FTTTAttributedLabel/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TTTAttributedLabel%2FTTTAttributedLabel/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/TTTAttributedLabel","download_url":"https://codeload.github.com/TTTAttributedLabel/TTTAttributedLabel/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TTTAttributedLabel%2FTTTAttributedLabel/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":267606706,"owners_count":24114772,"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-07-28T02:00:09.689Z","response_time":68,"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":[],"created_at":"2024-01-05T20:16:17.490Z","updated_at":"2025-08-03T00:31:57.320Z","avatar_url":"https://github.com/TTTAttributedLabel.png","language":"Objective-C","readme":"# TTTAttributedLabel\n\n[![Circle CI](https://circleci.com/gh/TTTAttributedLabel/TTTAttributedLabel.svg?style=svg)](https://circleci.com/gh/TTTAttributedLabel/TTTAttributedLabel) [![Version Status](https://img.shields.io/cocoapods/v/TTTAttributedLabel.svg)](https://cocoapods.org/pods/TTTAttributedLabel) [![codecov](https://codecov.io/gh/TTTAttributedLabel/TTTAttributedLabel/branch/master/graph/badge.svg)](https://codecov.io/gh/TTTAttributedLabel/TTTAttributedLabel) [![license MIT](https://img.shields.io/cocoapods/l/TTTAttributedLabel.svg)](http://opensource.org/licenses/MIT) [![Platform](https://img.shields.io/cocoapods/p/TTTAttributedLabel.svg)](http://cocoadocs.org/docsets/TTTAttributedLabel/)  [![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage)\n\n\n**A drop-in replacement for `UILabel` that supports attributes, data detectors, links, and more**\n\n`TTTAttributedLabel` is a drop-in replacement for `UILabel` providing a simple way to performantly render [attributed strings](https://developer.apple.com/library/mac/#documentation/Cocoa/Reference/Foundation/Classes/NSAttributedString_Class/Reference/Reference.html). As a bonus, it also supports link embedding, both automatically with `NSTextCheckingTypes` and manually by specifying a range for a URL, address, phone number, event, or transit information.\n\nEven though `UILabel` received support for `NSAttributedString` in iOS 6, `TTTAttributedLabel` has several unique features:\n\n- Automatic data detection\n- Manual link embedding\n- Label style inheritance for attributed strings\n- Custom styling for links within the label\n- Long-press gestures in addition to tap gestures for links\n\nIt also includes advanced paragraph style properties:\n\n- `attributedTruncationToken`\n- `firstLineIndent`\n- `highlightedShadowRadius`\n- `highlightedShadowOffset`\n- `highlightedShadowColor`\n- `lineHeightMultiple`\n- `lineSpacing`\n- `minimumLineHeight`\n- `maximumLineHeight`\n- `shadowRadius`\n- `textInsets`\n- `verticalAlignment`\n\n## Requirements\n\n- iOS 8+ / tvOS 9+\n- Xcode 7+\n\n### Accessibility\n\nAs of version 1.10.0, `TTTAttributedLabel` supports VoiceOver through the  `UIAccessibilityElement` protocol. Each link can be individually selected, with an `accessibilityLabel` equal to its string value, and a corresponding `accessibilityValue` for URL, phone number, and date links.  Developers who wish to change this behavior or provide custom values should create a subclass and override `accessibilityElements`.\n\n## Communication\n\n- If you **need help**, use [Stack Overflow](http://stackoverflow.com/questions/tagged/tttattributedlabel). (Tag `tttattributedlabel`)\n- If you'd like to **ask a general question**, use [Stack Overflow](http://stackoverflow.com/questions/tagged/tttattributedlabel).\n- If you **found a bug**, open an issue.\n- If you **have a feature request**, open an issue.\n- If you **want to contribute**, submit a pull request.\n\n## Installation\n\n[CocoaPods](https://cocoapods.org/) is the recommended method of installing `TTTAttributedLabel`. Simply add the following line to your `Podfile`:\n\n```ruby\n# Podfile\n\npod 'TTTAttributedLabel'\n```\n\n## Usage\n\n`TTTAttributedLabel` can display both plain and attributed text: just pass an `NSString` or `NSAttributedString` to the `setText:` setter. Never assign to the `attributedText` property.\n\n```objc\n// NSAttributedString\n\nTTTAttributedLabel *attributedLabel = [[TTTAttributedLabel alloc] initWithFrame:CGRectZero];\n\nNSAttributedString *attString = [[NSAttributedString alloc] initWithString:@\"Tom Bombadil\"\n                                                                attributes:@{\n        (id)kCTForegroundColorAttributeName : (id)[UIColor redColor].CGColor,\n        NSFontAttributeName : [UIFont boldSystemFontOfSize:16],\n        NSKernAttributeName : [NSNull null],\n        (id)kTTTBackgroundFillColorAttributeName : (id)[UIColor greenColor].CGColor\n}];\n\n// The attributed string is directly set, without inheriting any other text\n// properties of the label.\nattributedLabel.text = attString;\n```\n\n```objc\n// NSString\n\nTTTAttributedLabel *label = [[TTTAttributedLabel alloc] initWithFrame:CGRectZero];\nlabel.font = [UIFont systemFontOfSize:14];\nlabel.textColor = [UIColor darkGrayColor];\nlabel.lineBreakMode = NSLineBreakByWordWrapping;\nlabel.numberOfLines = 0;\n\n// If you're using a simple `NSString` for your text,\n// assign to the `text` property last so it can inherit other label properties.\nNSString *text = @\"Lorem ipsum dolor sit amet\";\n[label setText:text afterInheritingLabelAttributesAndConfiguringWithBlock:^ NSMutableAttributedString *(NSMutableAttributedString *mutableAttributedString) {\n  NSRange boldRange = [[mutableAttributedString string] rangeOfString:@\"ipsum dolor\" options:NSCaseInsensitiveSearch];\n  NSRange strikeRange = [[mutableAttributedString string] rangeOfString:@\"sit amet\" options:NSCaseInsensitiveSearch];\n\n  // Core Text APIs use C functions without a direct bridge to UIFont. See Apple's \"Core Text Programming Guide\" to learn how to configure string attributes.\n  UIFont *boldSystemFont = [UIFont boldSystemFontOfSize:14];\n  CTFontRef font = CTFontCreateWithName((__bridge CFStringRef)boldSystemFont.fontName, boldSystemFont.pointSize, NULL);\n  if (font) {\n    [mutableAttributedString addAttribute:(NSString *)kCTFontAttributeName value:(__bridge id)font range:boldRange];\n    [mutableAttributedString addAttribute:kTTTStrikeOutAttributeName value:@YES range:strikeRange];\n    CFRelease(font);\n  }\n\n  return mutableAttributedString;\n}];\n```\n\nFirst, we create and configure the label, the same way you would instantiate `UILabel`. Any text properties that are set on the label are inherited as the base attributes when using the `-setText:afterInheritingLabelAttributesAndConfiguringWithBlock:` method. In this example, the substring \"ipsum dolar\", would appear in bold, such that the label would read \"Lorem **ipsum dolar** sit amet\", in size 14 Helvetica, with a dark gray color.\n\n## `IBDesignable`\n\n`TTTAttributedLabel` includes `IBInspectable` and `IB_DESIGNABLE` annotations to enable configuring the label inside Interface Builder. However, if you see these warnings when building...\n\n```\nIB Designables: Failed to update auto layout status: Failed to load designables from path (null)\nIB Designables: Failed to render instance of TTTAttributedLabel: Failed to load designables from path (null)\n```\n\n...then you are likely using `TTTAttributedLabel` as a static library, which does not support IB annotations. Some workarounds include:\n\n- Install `TTTAttributedLabel` as a dynamic framework using CocoaPods with `use_frameworks!` in your `Podfile`, or with Carthage\n- Install `TTTAttributedLabel` by dragging its source files to your project\n\n### Links and Data Detection\n\nIn addition to supporting rich text, `TTTAttributedLabel` can automatically detect links for dates, addresses, URLs, phone numbers, transit information, and allows you to embed your own links.\n\n``` objective-c\nlabel.enabledTextCheckingTypes = NSTextCheckingTypeLink; // Automatically detect links when the label text is subsequently changed\nlabel.delegate = self; // Delegate methods are called when the user taps on a link (see `TTTAttributedLabelDelegate` protocol)\n\nlabel.text = @\"Fork me on GitHub! (https://github.com/mattt/TTTAttributedLabel/)\"; // Repository URL will be automatically detected and linked\n\nNSRange range = [label.text rangeOfString:@\"me\"];\n[label addLinkToURL:[NSURL URLWithString:@\"http://github.com/mattt/\"] withRange:range]; // Embedding a custom link in a substring\n```\n\n## Demo\n\n```bash\npod try TTTAttributedLabel\n```\n\n...or clone this repo and build and run/test the `Espressos` project in Xcode to see `TTTAttributedLabel` in action. If you don't have [CocoaPods](http://cocoapods.org) installed, grab it with `[sudo] gem install cocoapods`.\n\n```bash\ncd Example\npod install\nopen Espressos.xcworkspace\n```\n\n## License\n\n`TTTAttributedLabel` is available under the MIT license. See the LICENSE file for more info.\n","funding_links":[],"categories":["UI","Objective-C","Objective-C  Stars 1000以内排名整理","UI Components","Object-C 库","etc"],"sub_categories":["Label","Other free courses"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FTTTAttributedLabel%2FTTTAttributedLabel","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FTTTAttributedLabel%2FTTTAttributedLabel","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FTTTAttributedLabel%2FTTTAttributedLabel/lists"}