nsattributedstring

Very slow HTML rendering in NSAttributedString

ε祈祈猫儿з 提交于 2019-11-30 09:11:22
I have UITableView with dynamic sizing cells that displays list of comments in HTML format and I faced with the problem that NSAttributedString renders HTML content extremely slow! Here is snapshot from profiler. I tried to put the NSAttributedString initialization to separate thread, but still slow and user sees empty cells while HTML is being rendered and finally when it finished rendering cell is not layout properly. dispatch_async(GlobalQueue, { let html = NSAttributedString( data: self.comment.htmlBody.dataUsingEncoding(NSUnicodeStringEncoding, allowLossyConversion: false)!, options:

How to paste rich text into a UITextView?

好久不见. 提交于 2019-11-30 08:49:19
问题 My app allows users to format text in a UITextView by clicking some formatting buttons that apply attributes to the attributedText property of the text view. I want to allow users to copy their formatted text from one UITextView and paste it into another using the standard pasteboard and standard cut/copy/paste menu. Currently if I copy formatted text from a UITextView and paste it into a new message in the Mail app, the formatting is preserved -- so the copying of formatted text is happening

How to apply both bold and italic font to an NSAttributedString?

会有一股神秘感。 提交于 2019-11-30 08:27:07
问题 I'm trying to parse my own HTML string into an NSAttributedString for rendering in a UITextView. So, for when the string appears as such: <strong><em> This should be both bold and italic </strong></em> I want to apply a distinct bold and italic font to the eventual NSAttributedString, so that if the user ever removes either the bold or italic font from it during editing, one of the remaining fonts will stay intact. This is the main reason why I don't simply want to apply a single font style

UIPickerView won't allow changing font name and size via delegate's `attributedTitleForRow…`

ⅰ亾dé卋堺 提交于 2019-11-30 08:02:34
I use the following func to change the font color and font size, the color works but the font name and font size refuse to work. func pickerView(pickerView: UIPickerView, attributedTitleForRow row: Int, forComponent component: Int) -> NSAttributedString? var myTitle = NSAttributedString(string: titleData, attributes: [NSFontAttributeName:UIFont(name: "Arial-BoldMT", size: 45)!, NSForegroundColorAttributeName:UIColor.whiteColor()]) any help? Thx. I have a another option may be it helpfull for you.. Do all work that need for normal picker view : for more help UIPickerView make in Swift iOS Now

Preventing line breaks in part of an NSAttributedString

二次信任 提交于 2019-11-30 06:47:34
I am working on a UILabel which features large main text followed by smaller text that tells you who said it: Right now it is basically an NSAttributedString with a font attribute on the small text. I would like to set things up so the big text wraps but the small text doesn't. I.e., If the text will all fit on the same line as it does in the right item, it should render as is, but it it would wrap like in the left item, the whole of the small text should appear on the next line: The HTML equivalent of what I'm trying to achieve is: Title <nobr>Subtitle</nobr> - or - Title <span style="white

Change the color of a link in an NSMutableAttributedString

℡╲_俬逩灬. 提交于 2019-11-30 06:24:52
问题 I have the following code but my links are always blue. How do I cange the color of them? [_string addAttribute:NSLinkAttributeName value:tag range:NSMakeRange(position, length)]; [_string addAttribute:NSFontAttributeName value:[UIFont fontWithName:@"HelveticaNeue-Bold" size:(12.0)] range:NSMakeRange(position, length)]; [_string addAttribute:NSStrokeColorAttributeName value:[UIColor greenColor] range:NSMakeRange(position, length)]; _string is a NSMutableAttributedString and the position and

iOS UITableView with dynamic text and images rendered together (NSAttributedString + images)

半腔热情 提交于 2019-11-30 05:52:45
问题 My problem is this: I have dynamic content in an iOS app (such as twits - although this is not a twitter app) that include both text and images (mostly icons/emoticons and thumbnails). I want to render both text and images together in a table row. The main difficulty here is that each row will have a different size (making caching harder), and I need to calculate image size dynamically to fit text around on each image occurrence (I can have like 20 emoticons one next to another + text + more

Drop cap with NSAttributedString

为君一笑 提交于 2019-11-30 05:50:28
问题 I would like to do a drop cap first character in a UILabel using the attributedText NSAttributedString property only. Like this: (source: interpretationbydesign.com) I have experimented with adjusting the base line for the range of the first character to a negative value, and it works for aligning the top of the first char with the top of the rest of the first line. But I have not found any way to make the other lines flow to the right of the drop capped character. Can this be solved using

UITextView attributedText and syntax highlighting

六月ゝ 毕业季﹏ 提交于 2019-11-30 05:23:05
Background So, with iOS 6 an UITextView can take an attributedString, which could be useful for Syntax highlighting. I'm doing some regex patterns in -textView:shouldChangeTextInRange:replacementText: and oftentimes I need to change the color of a word already typed. I see no other options than resetting the attributedText, which takes time. - (BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text { //A context will allow us to not call -attributedText on the textView, which is slow. //Keep context up to date [self.context

How can I set the color and alignment of attributed text in a UITextView in iOS 7?

只愿长相守 提交于 2019-11-30 04:15:52
The formatting of my textViews worked fine in iOS 6, but no longer in iOS 7. I understand with Text Kit much of the under the hood stuff has changed. It's become really quite confusing, and I'm hoping someone can help straighten it out a bit by helping me with something as simple as this. My static UITextView originally was assigned a value for it's textColor and textAlignment properties. Then I made a NSMutableAttributedString , assigned it an attributes, then assigned it to the textView's attributedText property. The alignment and color no longer take effect in iOS 7. How can I fix this? If