2017-02-01 35 views

答えて

1

詰めペルシャ語やアラビア語のテキストを持つことはできません。

NSTextAlignmentJustifie 

と私はそのための明確な解決策を見つけることができません。私が参考に願っています

UITextView *textview = [[UITextView alloc]init]; 
[textview setAttributedText:[self MakeJustified_Text:mytext Font:[UIFont fontWithName:@"Font_Name" size:15]]]; 

- (NSMutableAttributedString *)MakeJustified_Text:(NSString *)text Font:(UIFont *)font{ 

NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc] init]; 
[paragraphStyle setBaseWritingDirection:NSWritingDirectionRightToLeft]; 
[paragraphStyle setAlignment:NSTextAlignmentJustified]; 
[paragraphStyle setLineSpacing:7]; 

NSMutableAttributedString* attrStr = [[NSMutableAttributedString alloc] initWithString: text]; 
[attrStr addAttribute:NSParagraphStyleAttributeName value:paragraphStyle range:NSMakeRange(0, attrStr.length)]; 

NSRange range = (NSRange){0,[attrStr length]}; 
[attrStr enumerateAttribute:NSFontAttributeName inRange:range options:NSAttributedStringEnumerationLongestEffectiveRangeNotRequired usingBlock:^(id value, NSRange range, BOOL *stop) { 
    UIFont *replacementFont = font; 
    [attrStr addAttribute:NSFontAttributeName value:replacementFont range:range]; 
}]; 
return attrStr;} 

今あなたが持っている任意のフォントと非常にシンプルなUITextViewやUILabelにこの方法を使用することができますので、私はこの方法多分他の開発者これに必要を作成します。

関連する問題