nsattributedstring

NSTextView with long NSMutableAttributedText low scrolling and loading speed

帅比萌擦擦* 提交于 2019-12-24 00:39:55
问题 I have a uitextview that most of times should show long attributedtexts . I use below code for creating my attributed text: //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(

How can I add different line spacing for different parts of NSAttributedString?

若如初见. 提交于 2019-12-23 23:57:54
问题 I want to have a single NSAttributedString contain multiple messages. If a single message has a long text and it wraps around, I want to have a line spacing of, say, 5. Because I have a single NSAttributedString contain multiple messages, I want to have a bigger line spacing between each message; let's say 20. What I want The 'I see' is one message. The 'I'd think it'd be both...' is one message, although it wraps down to two lines and 'Like a one way chat' is one message. Notice how the line

NSAttributedString initWithData:options:documentAttributes:error: painfully slow

孤街浪徒 提交于 2019-12-23 20:46:28
问题 I'm using those line of codes to create an attributed string from a simple HTML string: NSDictionary *importParams = @{ NSDocumentTypeDocumentAttribute: NSHTMLTextDocumentType,NSCharacterEncodingDocumentAttribute: @(NSUTF8StringEncoding) }; NSError *error = nil; NSData *stringData = [HTML dataUsingEncoding:NSUTF8StringEncoding] ; NSAttributedString *attributedString = [[NSAttributedString alloc] initWithData:stringData options:importParams documentAttributes:NULL error:&error]; The issue is

Which is the best approach among Autolayout or calculating the height using NSAttributedString, to implement dynamic height of an UITableViewCell?

拥有回忆 提交于 2019-12-23 19:13:04
问题 I have followed the tutorial from http://raywenderlich.com/73602/dynamic-table-view-cell-height-auto-layout and implemented the same, but with the release of iOS 8.3, the above tutorial doesn't seem to be working. Therefore i switched back to the following code which works absolutely fine -(float)height :(NSMutableAttributedString*)string { NSAttributedString *attributedText = string; CGRect rect = [attributedText boundingRectWithSize:CGSizeMake(200, MAXFLOAT) options:

Attributed text with two text alignments

☆樱花仙子☆ 提交于 2019-12-23 12:37:28
问题 Does anyone know how to achieve two different text alignments in one string? This is what I want the textView to show: label value My code: let txtView = cell.viewWithTag(77) as! UITextView let leftStyle = NSMutableParagraphStyle() leftStyle.alignment = NSTextAlignment.Left let rightStyle = NSMutableParagraphStyle() rightStyle.alignment = NSTextAlignment.Right let attText = NSMutableAttributedString(string: "label", attributes: [NSParagraphStyleAttributeName: leftStyle]) attText

UIButton setAttributedTitle: forState: Not Showing Up

北慕城南 提交于 2019-12-23 08:45:53
问题 I am trying to add underlining to my title on a custom UIButton but by following the example found here, I can't get it to show on the screen. Here is the code I am trying to use: NSMutableAttributedString *commentString = [[NSMutableAttributedString alloc] initWithString:@"The Quick Brown Fox"]; [commentString addAttribute:NSUnderlineStyleAttributeName value:[NSNumber numberWithInteger:NSUnderlineStyleSingle] range:NSMakeRange(0, [commentString length])]; [button setAttributedTitle

Sublassing NSMutableAttributedString returns SIGABRT on init

坚强是说给别人听的谎言 提交于 2019-12-23 08:04:09
问题 I created a subclass of NSMutableAttributedString in one of my projects to make a string that continually changes each character to one of the colors given in an array on init, but when I try to call the init method, I get a sigabrt on the initWithString: method. RainbowString.h #import <Foundation/Foundation.h> @interface RainbowString : NSMutableAttributedString @property (nonatomic) NSArray* colors; @property (nonatomic) NSTimeInterval duration; @property (nonatomic) NSTimer* timer; - (id

How to obtain plain 'globe' Unicode character

元气小坏坏 提交于 2019-12-23 07:59:39
问题 If you include Unicode characters in an NSString , a lot of them will take on the color set for that text - they're just regular glyphs for that font so they're displayed like any other character. But there are some Unicode characters that are colored, for example GLOBE WITH MERIDIANS which is a blue gradient with shadows. But I have seen this same glyph elsewhere that's a simple black outline without a shadow, for example in the iOS keyboard. I would like to use that glyph, but without the

Setting vertical align of truncated tails for NSAttributedString with NSTextAttachment

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-23 07:45:38
问题 I'm using the following code to generate a NSAttributedString for UILabel in iOS 8. // a long long Chinese title NSString *title = @"这是一个很长很长很长很长很长很长的中文标题"; // setup icon attachment NSTextAttachment *iconAttachment = [[NSTextAttachment alloc] init]; iconAttachment.image = [UIImage imageNamed:imageName]; iconAttachment.bounds = bounds; NSAttributedString *ycardImageString = [NSAttributedString attributedStringWithAttachment:iconAttachment]; // setup attributed text NSMutableAttributedString

Read RTFD data in IOS

心已入冬 提交于 2019-12-23 05:39:21
问题 I have RTFD data in NSData objects in IOS that I need to read. In MacOSX I just used to read them with NSAttributedString, but now I know that they are not supported in IOS. attribString = [[NSAttributedString alloc] initWithRTFD:note documentAttributes:&dict]; Is there any way to read only the text of the RTFD data in IOS? 回答1: The rtfd in iOS is something like as a directory. If you only want to get the text part, you can try: NSString *filePath = [[NSBundle mainBundle] pathForResource:@