Я получаю заголовок в формате HTML как
< span style = "color: # 000000; <strong> Пример </strong> </span> </p>
Мне нужно показать эту строку HTML в UILabel. Цветовой код и размер шрифта должны быть такими же, как и в HTML. Когда я преобразовываю HTML-строку в NSString, приходит только текст "Пример", а не цвет.
Есть ли какое-либо решение?
Thnx заранее
До сих пор я пытаюсь использовать NSAttributedString следующим образом, но таким образом весь HTML печатает:
UIFont *font = [UIFont systemFontOfSize:14.0];
UIFont *secondFont = [UIFont systemFontOfSize:10.0];
NSMutableDictionary *firstAttributes;
NSMutableDictionary *secondAttributes;
NSDictionary *firstAttributeFont = @{NSFontAttributeName:font};
NSDictionary *secondAttributeFont = @{NSFontAttributeName:secondFont};
[firstAttributes addEntriesFromDictionary:firstAttributeFont];
[secondAttributes addEntriesFromDictionary:secondAttributeFont];
[firstAttributes addEntriesFromDictionary:@{NSForegroundColorAttributeName:[UIColor clearColor]}];
[secondAttributes addEntriesFromDictionary:@{NSForegroundColorAttributeName:[UIColor clearColor]}];
NSString* completeString = [NSString stringWithFormat:@"%@",strTitle];
NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] initWithString:completeString];
[attributedString setAttributes:firstAttributes range:[completeString rangeOfString:strTitle]];
// [attributedString setAttributes:secondAttributes range:[completeString rangeOfString:self.secondAttributeText]];
Cell.lbl_Title.attributedText = attributedString;