Tag: nsattributedstring nsmutableattributedstring

NSTextView具有较长的NSMutableAttributedText低滚动和加载速度

我有一个uitextview大多数时候应该显示长的attributedtexts uitextview 。 我使用下面的代码来创build我的属性文本: //Add each line of doa to an element of array for future usage NSArray *paragraphs = [self.Text componentsSeparatedByString:@"\r\n"]; MixedContent= [[NSMutableAttributedString alloc]init]; ArabicContent= [[NSMutableAttributedString alloc]init]; TranslatedContent= [[NSMutableAttributedString alloc]init]; NSString * temp=@""; for (int i=0; i< paragraphs.count; i++) { if([paragraphs[i] hasPrefix:@"$2."]){ temp= [paragraphs[i] stringByReplacingOccurrencesOfString:@"$2." withString:@"" options:1 range:NSMakeRange(0, 3)]; NSMutableAttributedString* tempMutable= [[NSMutableAttributedString alloc] initWithString:temp […]

使用UITextView和NSMutableAttributedStringalignment文本

我试图把一个UITextView与NSMutableAttributedString合理的文本, NSMutableAttributedString由不同的NSAttributedString组成,因为我需要粗体和常规字体,所以我追加不同的NSString ,这是我的NSMutableAttributedString : NSAttributedString *one = [[NSAttributedString alloc] initWithString:@"abc" attributes:boldDict]; NSAttributedString *two = [[NSAttributedString alloc] initWithString:@" def" attributes:regularDict]; NSAttributedString *three = [[NSAttributedString alloc] initWithString:@" ghi" attributes:boldDict]; NSMutableAttributedString *string = [[NSMutableAttributedString alloc] initWithAttributedString:one]; [string appendAttributedString:two]; [string appendAttributedString:three]; 我试过这个: [self.text_view setTextAlignment:NSTextAlignmentJustified] 和这个: NSMutableParagraphStyle *paragraphStyles = [[NSMutableParagraphStyle alloc] init]; paragraphStyles.alignment = NSTextAlignmentJustified; Dictionary *attributes = @{NSParagraphStyleAttributeName: paragraphStyles}; […]

如何在我的UITextView使用NSMutableAttributedString加粗一些单词?

我有一个UITextView,并且有一些我正在使用NSString stringWithFormat进行投射,我想用粗体显示。 我已经看过周围堆栈溢出,并试图按照post,但我想我不理解它。 这是我一直在玩的东西: NSRange boldedRange = NSMakeRange(0, 4); NSString *boldFontName = [[UIFont fontWithName:@"Helvetica-Bold" size:100]fontName]; NSMutableAttributedString *attrString = [[NSMutableAttributedString alloc] initWithString:self.name]; [attrString beginEditing]; [attrString addAttribute:NSFontAttributeName value:boldFontName range:boldedRange]; [attrString endEditing]; self.resultsTextView.attributedText = attrString; self.resultsTextView.text = [NSString stringWithFormat:@"One day, %@ was taking a walk and saw a %@ boy. He was %@ a %@.", attrString, self.adjective, self.adverb, […]