Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- - (TTTAttributedLabel *)createAutoLayoutAttributedLabelWithFont:(UIFont *)font andColor:(UIColor *)color {
- TTTAttributedLabel *label = [[TTTAttributedLabel alloc] init];
- label.numberOfLines = 0;
- label.lineBreakMode = NSLineBreakByWordWrapping;
- label.translatesAutoresizingMaskIntoConstraints = NO;
- [label setPreferredMaxLayoutWidth:kPreferredMaxLayoutWidth];
- label.font = font;
- label.textColor = color;
- label.enabledTextCheckingTypes = NSTextCheckingAllTypes;
- if ([UIDevice canMakeCalls]) {
- NSArray *linkAttributesKeys = [[NSArray alloc] initWithObjects:(id)kCTForegroundColorAttributeName,(id)kCTUnderlineStyleAttributeName, nil];
- NSArray *linkAttributesObjects = [[NSArray alloc] initWithObjects:[UIColor oceanBlueColor],[NSNumber numberWithInt:kCTUnderlineStyleNone],nil];
- label.linkAttributes = [[NSDictionary alloc] initWithObjects:linkAttributesObjects forKeys:linkAttributesKeys];
- NSArray *activeAttributesKeys1 = [[NSArray alloc] initWithObjects:(id)kCTForegroundColorAttributeName,(id)kCTUnderlineStyleAttributeName, nil];
- NSArray *activeAttributesobjects = [[NSArray alloc] initWithObjects:[[UIColor oceanBlueColor] colorWithAlphaComponent:0.25f],[NSNumber numberWithInt:kCTUnderlineStyleNone],nil];
- label.activeLinkAttributes = [[NSDictionary alloc] initWithObjects:activeAttributesobjects forKeys:activeAttributesKeys1];
- } else {
- NSArray *keys = [[NSArray alloc] initWithObjects:(id)kCTForegroundColorAttributeName,(id)kCTUnderlineStyleAttributeName,(id)kCTFontAttributeName, nil];
- NSArray *objects = [[NSArray alloc] initWithObjects:color,[NSNumber numberWithInt:kCTUnderlineStyleNone],[UIFont fontWithName:kFontName size:font.pointSize] ,nil];
- label.linkAttributes = [[NSDictionary alloc] initWithObjects:objects forKeys:keys];
- label.activeLinkAttributes = [[NSDictionary alloc] initWithObjects:objects forKeys:keys];
- }
- label.delegate = self;
- return label;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement