CoreTextLabel
With CoreTextLabel you are able draw NSAttributedString or HTML with custom font and color in iOS (>= 5.0) applications. numberOfLines and truncation (NSLineBreakByTruncatingTail) is also supported.
Example
CoreTextLabel * label = [[CoreTextLabel alloc] initWithFrame:frame];
label.html = htmlString;
[label sizeToFit];
[self.view addSubview:label];
Install
Add CoreTextLabel pod to your Podfile.
$ vim Podfile
platform :ios, '5.0'
pod 'CoreTextLabel', :head
And then you install the dependencies in your project.
$ pod install
Remember to always open the Xcode workspace instead of the project file when you're building.
$ open App.xcworkspace
Requirements
CoreTextLabel 1.0 and higher requires iOS 5.0 and above.
Framework dependencies
- QuartzCore
- CoreText
ARC
CoreTextLabel uses ARC.
If you are using CoreTextLabel in your non-arc project, you will need to set a -fobjc-arc
compiler flag on all of the CoreTextLabel source files.
To set a compiler flag in Xcode, go to your active target and select the "Build Phases" tab. Now select all CoreTextLabel source files, press Enter, insert -fobjc-arc
or -fno-objc-arc
and then "Done" to enable or disable ARC for CoreTextLabel.
Credits
CoreTextLabel was created by Daniel Kuhnke for appfarms GmbH & Co. KG
License
CoreTextLabel is available under the MIT license. See the LICENSE file for more info.