Right to Left UILabels

I need to display text using UILabel (not use UIWebView), and sometimes it contains Hebrew and English. using the default UILabel settings, the sentence is mixed and does not make sense. I did not find a way to make UILabel text to display rtl.

Does anyone know all this, or the code that implements this?

+6
source share
2 answers

Take a look at this fooobar.com/questions/298802 / ... , it contains some information on this subject that may help you. This seems to work for some by adding the code \ u200F to the lines that will be displayed.

NSString *RTFstr = "1. בבוקר"; //This could be any right-to-left string NSString *directionalString = [@"\u200F" stringByAppendingString:[note text]]; [someUITextView setString:directionalString]; 
+6
source

It will work

 -(void)fnForWritingDirection:(UILabel*)label textFor:(NSString *)stringForText{ NSMutableAttributedString* attrStr = [[NSMutableAttributedString alloc] initWithString: [stringForText stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding]]; NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc] init]; [paragraphStyle setBaseWritingDirection:NSWritingDirectionRightToLeft]; [attrStr addAttribute:NSParagraphStyleAttributeName value:paragraphStyle range:NSMakeRange(0, [attrStr length])]; label.attributedText=attrStr; } 
+2
source

Source: https://habr.com/ru/post/898271/


All Articles