0

I am working on text editor app and using UITextView for this. Does anybody know how to make ability to do bullet/num/check lists in it? Any examples/tutorials?

Note: I need to do this as a part of text editor, so user can select some area, tap on according button and enable/disable lists formatting.

landonandrey
  • 1,271
  • 1
  • 16
  • 26

1 Answers1

1

Based on my research for similar behavior (e.g. Bullet list and Numbered list in UITextView ), I would expect that there is no easy way to do it. I expect that you will have to use textView(_:shouldChangeTextIn:replacementText:) to hack currently added text to manually add bullets/numbers - e.g., if the user set that she currently wants to use unordered list, you will have to detect a new line added in shouldChangeTextIn and manually add there the bullet and indentation.

Another approach which you might consider (its applicability depends on your requirements) is to customize existing open source rich text editor. In my case I was able to get close enough to what I needed using RichEditorView, which uses HTML+CSS as an underlying technology (so to be able to do customizations, you need to know a bit about JavaScript, CSS and HTML).

Milan Nosáľ
  • 19,169
  • 4
  • 55
  • 90
  • I don't want to use WebView :) Looking for TextKit examples. – landonandrey Mar 01 '18 at 11:01
  • @landonandrey I can understand that.. but I don't think somebody will implement it for you.. I believe it's not a task for couple of hours, but at least for couple of days, if not more.. that's why I ended with RichEditorView - because the client was not willing to spend that much time on it, and I was not able to find any ready example.. maybe someone else will have a solution though – Milan Nosáľ Mar 01 '18 at 11:05
  • @landonandrey and I see that we are working on similar things, just a week ago I have upvoted this question and answer of yours: https://stackoverflow.com/questions/34420344/custom-keyboard-extension-with-uitextfield – Milan Nosáľ Mar 01 '18 at 11:36
  • 1
    It seems like the next your project will be TextEditor hehe :) – landonandrey Mar 01 '18 at 11:39