Wrapping Text in a Uitextview Around a Uiimage Without Coretext

Wrapping Text in a UITextView Around a UIImage WITHOUT CoreText

This seems to do the trick:

UIBezierPath * imgRect = [UIBezierPath bezierPathWithRect:CGRectMake(0, 0, 100, 100)];
self.textView.textContainer.exclusionPaths = @[imgRect];

Works only from iOS 7 and up.

iOS Swift Wrapping Text Around Image

This is a perfectly reasonable use of a UITextView. Your reasons for hesitation to use it are unclear. You can make the UITextView non-editable and non-selectable; the user will not know that it is a UITextView as opposed to to a UILabel.

If you don't like that solution, then what I would do is use, instead of a UILabel, a custom view that draws the text. You can draw the text with Text Kit and thus you can take complete charge of how the text draws. In particular, you can cause it to wrap however you like, including not drawing the text in the corner (exclusion path on the text container).

How Can I Draw Image with Text Wrapping on iOS?

Yes, CoreText is the best way to do this. The code to do it is a little long to post here. Some code that may point you in the right direction is in the article "Clipping a CGRect to a CGPath." If the process for doing it is still confusing, ping me and I finally write the blog post I've been meaning to write on the subject.

How can I add UIView to UITextView

If you want to use https://github.com/vlas-voloshin/SubviewAttachingTextView
Just follow below link:

https://github.com/vlas-voloshin/SubviewAttachingTextView/blob/master/Example.playground/Contents.swift

iOS wrapping text around an image

I think your basic strategy should be (1) try to get the performance of UIWebView to an acceptable level and (2) if that fails, and it's really important, roll your own text layout code.

Some ideas:

  • Try to load content into the UIWebView class as early as possible, before it is displayed on screen.
  • See if using inline styles (instead of a linked stylesheet) improves load time.
  • See if using inline images (by using <img src="data:...") improves load time.

If none of that works, and you want to roll your own, you're going to have to write your own text layout code. You could probably do this by using NSString's UIKit additions: split the text into words, compute the size of each word (using sizeWithFont:), and lay out the text line by line. You should probably compute on a word-by-word basis, but actually draw a whole line at a time, that should perform better. Or you might be able to make a new string with newlines inserted at the right places and draw the whole thing in one go.

Good luck!

iOS how to insert UITextField inline within UITextView

You should take a closer look to CoreText which gives you a very fine grained access to text layout. But anyway, this is a difficult task. You may create a HTML-Page with input fields and display it in a WKWebView, which should be much easier to implement.

How to set UIView inside UITextView


You can wrap textfiled using below code

UIBezierPath * imgRect = [UIBezierPath bezierPathWithRect:CGRectMake(0, 0, 30, 30)];
self.textView.textContainer.exclusionPaths = @[imgRect];

And, now you can add any control in place of "imgRect"

 UIView *spacerView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 30, 30)];
spacerView1.backgroundColor = [UIColor redColor];
[textView addSubview:spacerView1];


Related Topics



Leave a reply



Submit