I have an html content that i want to show on UILabel.
NSAttributedString *attrStr = [[NSAttributedString alloc] initWithData:[htmlString dataUsingEncoding:NSUnicodeStringEncoding] options:@{
NSDocumentTypeDocumentAttribute: NSHTMLTextDocumentType}
documentAttributes:nil error:nil];
return attrStr;
This works good for English Language (LTR semantic), but since i want to support arabic as well the above method keeps the attributed string LTR.
Inspite of using this code : self.view.semanticContentAttribute = UISemanticContentAttributeForceRightToLeft;
I've tried
NSMutableAttributedString *mutableAttributedString = [[NSMutableAttributedString alloc]initWithData:[htmlString dataUsingEncoding:NSUnicodeStringEncoding] options:@{ NSDocumentTypeDocumentAttribute: NSHTMLTextDocumentType} documentAttributes:nil error:nil];
[mutableAttributedString addAttribute:NSWritingDirectionAttributeName value:@[@(NSWritingDirectionRightToLeft | NSWritingDirectionOverride)] range:NSMakeRange(0, string.length)];
return mutableAttributedString;
Still the same. Any suggestions are welcome. Thanks