How to set different colour Font text to single Label(Attributed Text)...
-(NSAttributedString *)AttrStr:(NSString *)str1 fontString:(NSString *)str2 {
NSDictionary *dict1;
NSDictionary *dict2;
dict1 = @{NSFontAttributeName:[UIFont fontWithName:promptLight size:10.0],NSForegroundColorAttributeName:[UIColor colorWithRed:127/255.0 green:127/255.0 blue:127/255.0 alpha:1.0]};
dict2 = @{NSFontAttributeName:[UIFont fontWithName:promptLight size:10.0],NSForegroundColorAttributeName:[UIColor colorWithRed:78/255.0 green:186/255.0 blue:222/255.0 alpha:1.0]};
NSMutableAttributedString *attString = [[NSMutableAttributedString alloc] init];
[attString appendAttributedString:[[NSAttributedString alloc] initWithString:str1 attributes:dict1]];
[attString appendAttributedString:[[NSAttributedString alloc] initWithString:str2 attributes:dict2]];
return attString;
}
cell.LSALbl.attributedText = [self AttrStr:@"LSA: " fontString:[NSString stringWithFormat:@"%ld",lroundf([_productionDataObj.lsaPlanned floatValue])]];
No comments:
Post a Comment