textkit

UITextView textContainerInset not respecting bottom inset value

断了今生、忘了曾经 提交于 2019-11-30 11:35:02
I have a UIView displaying an NSAttributedString. It's set up to resize to fit its contents. I'd like to create some padding between the text and the view, however it's not quite working. If I do this... view.textContainerInset = UIEdgeInsetsMake(0, 15, 0, 15); ... then the left and right edges are padded, and the top and bottom have no space. This is correct. I then add in a top inset: view.textContainerInset = UIEdgeInsetsMake(15, 15, 0, 15); Now the top has 15 points padding, but suddenly the bottom is padded a little too (by about 10 points). If I then add 15 points bottom padding the

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

How to fit text in a circle in UILabel

醉酒当歌 提交于 2019-11-30 03:52:44
I'd like to flow the text in UILabel into a circle (instead of rect). I did some experiments with NSLayoutManager , NSTextContainer and NSTextStorage but it does not seem to work. The example below is supposed to flow the text into a smaller rect of 40x40 (label is 120x120) but does not seem to have any effect. UIFont *font = [UIFont fontWithName:@"HelveticaNeue" size:12]; NSTextStorage *ts = [[NSTextStorage alloc] initWithString:multiline.title attributes:@{NSFontAttributeName:font}]; NSLayoutManager *lm = [[NSLayoutManager alloc] init]; NSTextContainer *tc = [[NSTextContainer alloc]

Animated UIImage in UITextView with TextKit

允我心安 提交于 2019-11-30 01:31:47
问题 I have a UIImage that contains multiple image frames and a duration which was sliced together from an animated GIF file. If I load the image in a UIWebView it will animate as expected, but I want to use a UITextView instead. The obvious choice is to use TextKit with a custom NSLayoutManger and many custom NSAttributedString attributes to achieve various drawing effects. I have a single UITextView that I'd like to give a NSAttributedString that contains NSTextAttachment s for all of the images

Adjust letter spacing in iOS 7

南楼画角 提交于 2019-11-29 22:54:15
In iOS 7, when navigating back using the new swipe-from-edge-of-screen gesture, the title of the Back button ("Artists") fades from being pink (in the example below) and having regular font weight to being black and having bold font weight. It seems to me that the animation uses two different labels in order to achieve this effect; one fading out as the other fades in. However, Apple has somehow adjusted the font so that the regular label perfectly overlays the bold one, thus creating the illusion of a single label morphing between two different weights and colors. Have they simply adjusted

NSAttributedString changed font unexpectedly after inserting Image

爷,独闯天下 提交于 2019-11-29 20:21:27
问题 I am using Text Kit in iOS 7 to create a rich text editor. Following is the problem. At first, then font size is 16: Then I insert an image using the code: // Image Attachment NSTextAttachment *imageAttachment = [[NSTextAttachment alloc] init]; [imageAttachment setImage:image]; imageAttachment.bounds = CGRectMake(0, 0, width, height); [self insertTextAttachment:imageAttachment]; and - (void)insertTextAttachment:(NSTextAttachment*)textAttachment { NSMutableAttributedString *newContent = [

UITextView textContainerInset not respecting bottom inset value

↘锁芯ラ 提交于 2019-11-29 17:08:30
问题 I have a UIView displaying an NSAttributedString. It's set up to resize to fit its contents. I'd like to create some padding between the text and the view, however it's not quite working. If I do this... view.textContainerInset = UIEdgeInsetsMake(0, 15, 0, 15); ... then the left and right edges are padded, and the top and bottom have no space. This is correct. I then add in a top inset: view.textContainerInset = UIEdgeInsetsMake(15, 15, 0, 15); Now the top has 15 points padding, but suddenly

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

Newlines in iOS 7 UITextView breaking Text Kit exclusion zone wrapping

吃可爱长大的小学妹 提交于 2019-11-29 02:31:06
I'm working with Text Kit in iOS 7 and I'm finding a lot of oddities around NSTextContainer exclusion zones. I've got two views: a UITextView and a simple draggable UIView ; as the UIView moves, I create a bezier path from the UIView 's frame (adjusted to within the UITextView 's coordinate space) and I update the UITextView 's NSTextContainer 's exclusionPaths array - pretty straightforward. In the first screenshot, you can see that Text Kit nicely wraps text around a rectangular exclusion zone: However, when the user introduces newlines into the UITextView , TextKit seems to think that the

How to fit text in a circle in UILabel

半腔热情 提交于 2019-11-29 00:51:03
问题 I'd like to flow the text in UILabel into a circle (instead of rect). I did some experiments with NSLayoutManager , NSTextContainer and NSTextStorage but it does not seem to work. The example below is supposed to flow the text into a smaller rect of 40x40 (label is 120x120) but does not seem to have any effect. UIFont *font = [UIFont fontWithName:@"HelveticaNeue" size:12]; NSTextStorage *ts = [[NSTextStorage alloc] initWithString:multiline.title attributes:@{NSFontAttributeName:font}];