Showing posts with label Truncation. Show all posts
Showing posts with label Truncation. Show all posts

February 17, 2007

Text control with truncateToFit property support

As you probably know, Label control supports truncateToFit property, while Text doesn't. Even if you explicitly set it to true in your particular Text instance, nothing happens. I have created TruncatedText class that acts the similar way as Label does. If a TruncatedText instance is sized to be smaller than its text, the text is truncated with "...":

December 12, 2006

truncateToFit() performance problem

Setting very long string to the text property of classes that decorate UITextField (e. g. Label) causes timeout exception. Take a look at the truncateToFit() method in UITextField class. You could find this block there:

It means that actual text is cut char by char until result of its concatenation with truncation indicator fits into the width available or only one char left. When text is very long this looping is almost infinitive. I believe it would work much more faster with division by 2 approach. In this case even 64K text truncation will take only 16 loop cycles.