TTTAttributedLabel Deployment and Usage Guide
Prerequisites
- iOS 8+ / tvOS 9+ - Minimum deployment target for the library
- Xcode 7+ - Required development environment
- Objective-C - The library is written in Objective-C
- CocoaPods - Recommended dependency manager (optional but preferred)
Installation
Using CocoaPods (Recommended)
-
Install CocoaPods if not already installed:
sudo gem install cocoapods -
Create a
Podfilein your project directory if it doesn't exist:pod init -
Add the following line to your
Podfile:pod 'TTTAttributedLabel' -
Install the pod:
pod install -
Open your project using the generated
.xcworkspacefile instead of.xcodeproj.
Manual Installation
-
Download the source code from the repository:
git clone https://github.com/TTTAttributedLabel/TTTAttributedLabel.git -
Add
TTTAttributedLabel.handTTTAttributedLabel.mfiles to your Xcode project. -
Ensure the files are added to your target in the "Build Phases" section.
Configuration
No additional configuration files or environment variables are required for TTTAttributedLabel. The library is designed as a drop-in replacement for UILabel and works out of the box.
Accessibility Configuration
For custom accessibility behavior, create a subclass and override the accessibilityElements method:
@interface CustomTTTAttributedLabel : TTTAttributedLabel
@end
@implementation CustomTTTAttributedLabel
- (NSArray *)accessibilityElements {
// Custom accessibility implementation
}
@end
Build & Run
Development
-
Open your project in Xcode using the
.xcworkspacefile (if using CocoaPods). -
Import the header in your view controller:
#import <TTTAttributedLabel/TTTAttributedLabel.h> -
Create and configure the label:
TTTAttributedLabel *label = [[TTTAttributedLabel alloc] initWithFrame:CGRectZero]; label.font = [UIFont systemFontOfSize:14]; label.textColor = [UIColor darkGrayColor]; label.numberOfLines = 0; -
Set text with attributes:
NSString *text = @"Lorem ipsum dolor sit amet"; [label setText:text afterInheritingLabelAttributesAndConfiguringWithBlock:^ NSMutableAttributedString *(NSMutableAttributedString *mutableAttributedString) { NSRange boldRange = [[mutableAttributedString string] rangeOfString:@"ipsum dolor" options:NSCaseInsensitiveSearch]; UIFont *boldSystemFont = [UIFont boldSystemFontOfSize:14]; CTFontRef font = CTFontCreateWithName((__bridge CFStringRef)boldSystemFont.fontName, boldSystemFont.pointSize, NULL); if (font) { [mutableAttributedString addAttribute:(NSString *)kCTFontAttributeName value:(__bridge id)font range:boldRange]; CFRelease(font); } return mutableAttributedString; }];
Production
For production builds, ensure:
- All link detection and attributed string configurations are tested
- Accessibility features are properly configured for VoiceOver support
- Performance is validated with long text content
Deployment
TTTAttributedLabel is a library component, not a standalone application. Deploy your application containing TTTAttributedLabel to:
- App Store - Standard iOS app distribution
- Enterprise Distribution - For internal company apps
- TestFlight - For beta testing
No special deployment steps are required for the library itself.
Troubleshooting
Common Issues and Solutions
1. Label not displaying attributed text
Issue: Text appears plain without attributes
Solution: Ensure you're using setText: or setText:afterInheritingLabelAttributesAndConfiguringWithBlock: instead of attributedText property.
2. Link detection not working
Issue: URLs, phone numbers, or addresses aren't detected automatically
Solution: Set the enabledTextCheckingTypes property:
label.enabledTextCheckingTypes = NSTextCheckingTypeLink | NSTextCheckingTypePhoneNumber | NSTextCheckingTypeAddress;
3. Memory leaks with Core Text
Issue: Memory warnings or leaks when using Core Text APIs Solution: Always release Core Text objects:
CTFontRef font = CTFontCreateWithName(...);
// Use font
CFRelease(font);
4. Accessibility elements not working
Issue: VoiceOver doesn't read links correctly Solution: Ensure you're using version 1.10.0 or later, and configure accessibility elements if needed.
5. Build errors with CocoaPods
Issue: "No such module 'TTTAttributedLabel'"
Solution: Run pod install and open the .xcworkspace file, not .xcodeproj.
6. Text not inheriting label attributes
Issue: Custom attributes aren't being applied
Solution: Use the afterInheritingLabelAttributesAndConfiguringWithBlock: method to ensure proper attribute inheritance.