I am using NSAttributedString UIKit Additions to draw an attribute string in a UIView. The problem is that despite using the NSWritingDirectionNatural value for the NSWritingDirectionNatural property of my paragraph style, the text always defaults from left to right.
This is how I form the sent string (simplified):
NSString *arabic = @"العاصمة الليبية لتأمينها تنفيذا لقرار المؤتمر الوطني العام. يأتي ذلك بعدما أعلن اللواء الليبي المتقاعد خليفة حفتر أنه طلب من المجلس الأعلى للقض الدولة حتى الانتخابات النيابية القادمة"; NSMutableParagraphStyle *paragraph = [[NSMutableParagraphStyle alloc] init]; paragraph.baseWritingDirection = NSWritingDirectionNatural; paragraph.lineBreakMode = NSLineBreakByWordWrapping; NSMutableDictionary *attributes = [[NSMutableDictionary alloc] init]; attributes[NSParagraphStyleAttributeName] = paragraph; NSAttributedString *string = [[NSAttributedString alloc] initWithString:arabic attributes:attributes]; لتأمينها تنفيذا لقرار المؤتمر الوطني العام يأتي ذلك بعدما أعلن اللواء الليبي المتقاعد خليفة حفتر أنه طلب من المجلس الأعلى للقض الدولة حتى الانتخابات النيابية القادمة."; NSString *arabic = @"العاصمة الليبية لتأمينها تنفيذا لقرار المؤتمر الوطني العام. يأتي ذلك بعدما أعلن اللواء الليبي المتقاعد خليفة حفتر أنه طلب من المجلس الأعلى للقض الدولة حتى الانتخابات النيابية القادمة"; NSMutableParagraphStyle *paragraph = [[NSMutableParagraphStyle alloc] init]; paragraph.baseWritingDirection = NSWritingDirectionNatural; paragraph.lineBreakMode = NSLineBreakByWordWrapping; NSMutableDictionary *attributes = [[NSMutableDictionary alloc] init]; attributes[NSParagraphStyleAttributeName] = paragraph; NSAttributedString *string = [[NSAttributedString alloc] initWithString:arabic attributes:attributes];
And this is how I draw the text:
- (void)drawRect:(CGRect)rect { [self.attributedText drawWithRect:rect options:NSStringDrawingUsesLineFragmentOrigin context:nil]; }
And yet it still flows from left to right:

What am I missing?
source share