{"id":2585,"url":"https://github.com/tobihagemann/THLabel","last_synced_at":"2025-08-03T00:31:58.959Z","repository":{"id":6059591,"uuid":"7284995","full_name":"tobihagemann/THLabel","owner":"tobihagemann","description":"UILabel subclass, which additionally allows shadow blur, inner shadow, stroke text and fill gradient.","archived":false,"fork":false,"pushed_at":"2022-09-30T17:53:31.000Z","size":408,"stargazers_count":669,"open_issues_count":10,"forks_count":110,"subscribers_count":31,"default_branch":"main","last_synced_at":"2024-12-04T02:50:10.954Z","etag":null,"topics":["gradient","objective-c","shadow","stroke","uilabel"],"latest_commit_sha":null,"homepage":"https://tobiha.de","language":"Objective-C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tobihagemann.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null},"funding":{"github":"tobihagemann"}},"created_at":"2012-12-22T10:58:50.000Z","updated_at":"2024-11-20T03:49:31.000Z","dependencies_parsed_at":"2022-09-10T02:51:26.479Z","dependency_job_id":null,"html_url":"https://github.com/tobihagemann/THLabel","commit_stats":null,"previous_names":[],"tags_count":30,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tobihagemann%2FTHLabel","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tobihagemann%2FTHLabel/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tobihagemann%2FTHLabel/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tobihagemann%2FTHLabel/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tobihagemann","download_url":"https://codeload.github.com/tobihagemann/THLabel/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":228510736,"owners_count":17931759,"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":["gradient","objective-c","shadow","stroke","uilabel"],"created_at":"2024-01-05T20:16:17.616Z","updated_at":"2024-12-06T18:30:35.009Z","avatar_url":"https://github.com/tobihagemann.png","language":"Objective-C","funding_links":["https://github.com/sponsors/tobihagemann"],"categories":["UI","Objective-C"],"sub_categories":["Label","Other free courses"],"readme":"# THLabel\n\n[![CocoaPods Compatible](https://img.shields.io/cocoapods/v/THLabel.svg)](https://img.shields.io/cocoapods/v/THLabel.svg)\n[![Carthage Compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage)\n[![Platform](https://img.shields.io/cocoapods/p/THLabel.svg?style=flat)](http://cocoadocs.org/docsets/THLabel)\n[![Twitter](https://img.shields.io/badge/twitter-@tobihagemann-blue.svg?style=flat)](https://twitter.com/tobihagemann)\n\nTHLabel is a subclass of UILabel, which additionally allows shadow blur, inner shadow, stroke text and fill gradient.\n\n![THLabel screenshot](https://raw.githubusercontent.com/tobihagemann/THLabel/master/screenshot.png \"THLabel screenshot\")\n\n## Requirements\n\n* iOS 4.0 or higher (below iOS 7.0 is untested though)\n* ARC enabled\n\n## Installation\n\nThe easiest way to use THLabel in your app is via [CocoaPods](http://cocoapods.org/ \"CocoaPods\").\n\n1. Add the following line in the project's Podfile file: `pod 'THLabel', '~\u003e 1.4.0'`\n2. Run the command `pod install` from the Podfile folder directory.\n\n### Manual Installation\n\n1. Add `CoreText.framework` to your *Link Binary with Libraries* list.\n2. Drag these files into your project: `THLabel.h`, `THLabel.m`\n\n## IBDesignable / IBInspectable\n\nThere is an `ibdesignable` branch, if you're interested in this feature. It has been removed from the `master` branch, because IBDesignable and IBInspectable cause problems with CocoaPods, if you're not using `use_frameworks!` in your Podfile.\n\n## Usage\n\nYou can create THLabels programmatically, or create them in Interface Builder by dragging an ordinary UILabel into your view and setting its *Custom Class* to THLabel. With Xcode 6 you can set most of the properties within Interface Builder, which will preview your changes immediately.\n\n## Properties\n\n### Spacing\n\n```objective-c\n@property CGFloat letterSpacing;\n@property CGFloat lineSpacing;\n```\n\nYou can modify letter spacing of the text (also known as kerning) by changing the `letterSpacing` property. The default value is `0.0`. A positive value will separate the characters, whereas a negative value will make them closer.\n\nModify line spacing of the text (also known as leading) by changing the `lineSpacing` property. The default value is `0.0`. Only positive values will have an effect.\n\n### Shadow Blur\n\n```objective-c\n@property CGFloat shadowBlur;\n```\n\nAdditionally to UILabel's `shadowColor` and `shadowOffset`, you can set a shadow blur to soften the shadow.\n\n### Inner Shadow\n\n```objective-c\n@property CGFloat innerShadowBlur;\n@property CGSize innerShadowOffset;\n@property UIColor *innerShadowColor;\n```\n\nThe inner shadow has similar properties as UILabel's shadow, once again additionally with a shadow blur. If an inner shadow and a stroke are overlapping, it will appear beneath the stroke.\n\n### Stroke Text\n\n```objective-c\n@property CGFloat strokeSize;\n@property UIColor *strokeColor;\n@property THLabelStrokePosition strokePosition;\n```\n\nYou can set an outer, centered or inner stroke by setting the `strokePosition` property. Default value is `THLabelStrokePositionOutside`. Other options are `THLabelStrokePositionCenter` and `THLabelStrokePositionInside`.\n\n### Fill Gradient\n\n```objective-c\n@property UIColor *gradientStartColor;\n@property UIColor *gradientEndColor;\n@property NSArray *gradientColors;\n@property CGPoint gradientStartPoint;\n@property CGPoint gradientEndPoint;\n```\n\nThe gradient can consist of multiple colors, which have to be saved as UIColor objects in the `gradientColors` array. For more convenience, `gradientStartColor` and `gradientEndColor` will fill up the array accordingly.\n\nThe starting and ending points of the gradient are in the range 0 to 1, where (0, 0) is the top-left and (1, 1) the bottom-right of the text. The default value for `gradientStartPoint` is (0.5, 0.2) and for `gradientEndPoint` it is (0.5, 0.8).\n\n### Fade Truncating\n\n```objective-c\n@property THLabelFadeTruncatingMode fadeTruncatingMode;\n```\n\nYou can fade in/out your label by setting the `fadeTruncatingMode` property. Default value is `THLabelFadeTruncatingModeNone`. The options are `THLabelFadeTruncatingModeTail`, `THLabelFadeTruncatingModeHead` and `THLabelFadeTruncatingModeHeadAndTail`.\n\n### Text Insets / Padding\n\n```objective-c\n@property UIEdgeInsets textInsets;\n@property BOOL automaticallyAdjustTextInsets;\n```\n\nEffects like stroke and shadow can't be drawn outside of the bounds of the label view. You may need to set text insets to move a bit away from the edge so that the effects don't get clipped. This will be automatically done if you set `automaticallyAdjustTextInsets` to `YES`, which is also the default value.\n\n## Notes\n\nTHLabel respects (unlike UILabel) the `contentMode` property, which is used for vertical alignment. The `textAlignment` still has the higher priority, when it comes to horizontal alignment.\n\nHowever THLabel doesn't respect the `numberOfLines` property, because Core Text doesn't support it natively. If you would like to have multiple lines, set `lineBreakMode` to `NSLineBreakByWordWrapping`.\n\nTHLabels are slower to draw than UILabels, so be aware of that.\n\n## Credits\n\nOriginal source and inspiration from:\n\n- FXLabel by Nick Lockwood, https://github.com/nicklockwood/FXLabel\n- KSLabel by Kai Schweiger, https://github.com/vigorouscoding/KSLabel\n- GTMFadeTruncatingLabel by Google, https://github.com/google/google-toolbox-for-mac/tree/master/iPhone\n\nBig thanks to Jason Miller for showing me sample code of his implementation using Core Text! It inspired me to dig deeper and move away from drawing with NSAttributedString on iOS 7, which caused a lot of problems.\n\n## License\n\nDistributed under the permissive zlib license. See the LICENSE file for more info.\n\n## Contact\n\nTobias Hagemann\n\n- https://tobiha.de/\n- tobias.hagemann@gmail.com\n- https://twitter.com/tobihagemann\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftobihagemann%2FTHLabel","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftobihagemann%2FTHLabel","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftobihagemann%2FTHLabel/lists"}