mattt/TTTAttributedLabel — Issue #36: Links towards bottom don't work in tall labels
Author: adamjernst
Created: 2011-12-10 16:36:14+00:00
State: open

In `characterIndexAtPoint:`, the label calls `textRectForBounds:limitedToNumberOfLines:`:

CGRect textRect = [self textRectForBounds:self.bounds limitedToNumberOfLines:self.numberOfLines];

This is not correct. First, `textRectForBounds:limitedToNumberOfLines:` will return a measurement based on the unattributed `text` property, not the attributed string currently in the label. The label should override `textRectForBounds:limitedToNumberOfLines:` and return an appropriate measurement.

This also means the vertical-alignment code in `drawTextInRect:` should be pulled out into an appropriately generic method to get the text rect for a given bounds rectangle. Right now links don't take vertical alignment into account at all.

This bug manifests as links towards the bottom of a tall label failing to respond to taps. This is because they are outside the rectangle returned by `textRectForBounds:limitedToNumberOfLines:`.