Giter VIP home page Giter VIP logo

mhtextview's Introduction

MHTextView

This is a text view that solves a few tasks that cannot be solved using UILabel or UITextView. It is not a complete UITextView replacement and doesn't support editing or text selection, for example.

Main features:

  • Optional custom justify. The default justification implementation "stretches" words early on, it increases the letter-spacing. By contrast, the custom justification in MHTextView only increases the whitespace and leaves the letter-spacing untouched, unless there is only one word on a line.

  • Ellipsis on last line. Optionally adds an ellipsis at the end of the text if it doesn't fit and overflows.

  • Custom layouts. The default layout, MHDefaultTextViewLayout, already provides support for multiple columns. If you need more fancy layouts you can implement your own. The demo project provides examples.

  • Exclusion paths. You can provide arbitrary UIBezierPaths into which the text view is not allowed to render (to "cut" holes into your text).

  • Exclusion views. Similar to exclusion paths, the text view can track other views and use their frames as exclusion paths so you don't have to provide the corresponding paths yourself.

  • Top-to-bottom text distribution for multi-column layouts. Usually, text is distributed by completely filling the first column, then proceeding to the next until the text runs out. With this setting the text is distributed over the columns in such a way that they all have the same height, if possible.

The provided demo project let's you play with all of these settings.

Known issues and limitations

  • The ellipsis sometimes removes the last one or two characters of the last word.
  • AutoLayout intrinsic content height is only supported for single-column setup when using MHDefaultTextViewLayout.

License

BSD-style. See LICENSE file.

mhtextview's People

Contributors

darkdust avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar

mhtextview's Issues

Ellipsis sometimes cuts off words

Sometimes the ellipsis isn't truncating text cleanly. Instead of:

Foobar…

it sometimes produces

Foob…

That is, the last character (one or two) of the last word are removed. Should be avoided if possible. Since that's an artifact of CTLineCreateTruncatedLine I'm not yet sure how to handle this.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.