nstextattachment

Change size of NSTextAttachment Image?

99封情书 提交于 2019-12-01 10:50:48
I am using the following code to format the raw HTML of an RSS feed into an NSAttributedString . The HTML contains <img> tags that cause the image to be attached as an NSTextAttachment into the NSAttributedString . The problem is that the image is far too large for the UITextView that the attributed string is placed in. Is there a way I can manipulate the size of the image from within the attributed string? Below is an excerpt from the whole attributed string that represents the image attachment. { NSAttachment = "<NSTextAttachment: 0x16d29450> \"e0e1d483a922419807a2378a7ec031af.jpg\"";

Change size of NSTextAttachment Image?

情到浓时终转凉″ 提交于 2019-12-01 09:40:36
问题 I am using the following code to format the raw HTML of an RSS feed into an NSAttributedString . The HTML contains <img> tags that cause the image to be attached as an NSTextAttachment into the NSAttributedString . The problem is that the image is far too large for the UITextView that the attributed string is placed in. Is there a way I can manipulate the size of the image from within the attributed string? Below is an excerpt from the whole attributed string that represents the image

Redrawing NSTextAttachments in an UITextView with attributed text

此生再无相见时 提交于 2019-11-30 09:39:18
I have a NSTextAttachment subclass with overridden attachmentBoundsForTextContainer:proposedLineFragment:glyphPosition:characterIndex: imageForBounds:textContainer:characterIndex: . I need to redraw the attachment(s) at some point. Calling setNeedsDisplay on the UITextView doesn't work. Any ideas? I'd like to avoid recreating attachments and/or the attributed string. You'll want to use one of textView.layoutManager 's methods. invalidateDisplayCharacterRange: imageForBounds:textContainer:characterIndex: will be called again. attachmentBoundsForTextContainer:[...]Index: will not be called again

In a UILabel, is it possible to force a line NOT to break in a certain place

点点圈 提交于 2019-11-30 01:08:31
问题 I have a UILabel that is supposed to be two lines long. The text is localized into French and English. I'm setting the attributedText property of the label. The text is constructed from three appended strings, say textFragment1, textFragment2 and textFragment3. The middle string is actually an image created with an NSTextAttachment. I want to make sure that textFragment2 and textFragment3 are on the same line. The first string may or may not wrap depending on how long it is. The problem is

Redrawing NSTextAttachments in an UITextView with attributed text

落花浮王杯 提交于 2019-11-29 14:37:28
问题 I have a NSTextAttachment subclass with overridden attachmentBoundsForTextContainer:proposedLineFragment:glyphPosition:characterIndex: imageForBounds:textContainer:characterIndex: . I need to redraw the attachment(s) at some point. Calling setNeedsDisplay on the UITextView doesn't work. Any ideas? I'd like to avoid recreating attachments and/or the attributed string. 回答1: You'll want to use one of textView.layoutManager 's methods. invalidateDisplayCharacterRange: imageForBounds:textContainer

Lines missing from tall UILabel when embedding NSTextAttachment

陌路散爱 提交于 2019-11-29 03:07:32
I can create a multi-line NSAttributedString by using escaped new-line characters ( @"\n" ). With iOS 7, I can now embed a UIImage inside attributed strings (via NSTextAttachment ). I have noticed that whenever I set the attributedText of a UILabel to a multi-line attributed string with an embedded image, the number of lines actually displayed is inversely proportional to the height of the label. For example, when the height of the label is 80, two lines appear; when the height is around 100, only the second line appears; when the height is about 130, nothing appears. This problem occurred

How to subclass NSTextAttachment?

跟風遠走 提交于 2019-11-28 17:39:19
Here is my problem: I use Core Data to store rich text input from iOS and/or OS X apps and would like images pasted into the NSTextView or UITextView to: a) retain their original resolution, and b) on display to be scaled to fit the textView correctly, which means scaling based on the size of the view on the device. Currently I am using - (void)textStorage:(NSTextStorage *)textStorage didProcessEditing:(NSTextStorageEditActions)editedMask range:(NSRange)editedRange changeInLength:(NSInteger)delta to look for attachments and to then generate an image with a scale factor and assigning it to the

How to subclass NSTextAttachment?

半世苍凉 提交于 2019-11-27 10:38:07
问题 Here is my problem: I use Core Data to store rich text input from iOS and/or OS X apps and would like images pasted into the NSTextView or UITextView to: a) retain their original resolution, and b) on display to be scaled to fit the textView correctly, which means scaling based on the size of the view on the device. Currently I am using - (void)textStorage:(NSTextStorage *)textStorage didProcessEditing:(NSTextStorageEditActions)editedMask range:(NSRange)editedRange changeInLength:(NSInteger

how to resize an image or done as a NSAttributedString NSTextAttachment (or set its initital size)

烂漫一生 提交于 2019-11-27 08:51:41
I have a NSAttributedString to which I am adding a NSTextAttachment. The image is 50w by 50h but I'd like it to scale down to reflect the line height of the attributed string. I thought this would be done automatically but I guess not. I have looked at the UImage class reference but this image doesn't seem to be set in a UIImageView so no access to a frame property. Here's a screenshot of what I currently have: In an ideal world, I would also like to implement a way to scale up the image based upon user input (such as increasing the font size). Any ideas on how to achieve this? thx edit 1 here

how to resize an image or done as a NSAttributedString NSTextAttachment (or set its initital size)

血红的双手。 提交于 2019-11-26 17:46:56
问题 I have a NSAttributedString to which I am adding a NSTextAttachment. The image is 50w by 50h but I'd like it to scale down to reflect the line height of the attributed string. I thought this would be done automatically but I guess not. I have looked at the UImage class reference but this image doesn't seem to be set in a UIImageView so no access to a frame property. Here's a screenshot of what I currently have: In an ideal world, I would also like to implement a way to scale up the image