Krelborn / KILabel

A simple to use drop in replacement for UILabel for iOS 7 and above that highlights links such as URLs, twitter style usernames and hashtags and makes them touchable.
MIT License
470 stars 132 forks source link

Wrong height when string contains trailing "\n" #18

Closed d6u closed 9 years ago

d6u commented 9 years ago

image

The left string was I ♥ that #RainbowStarDay came back for week 2\n\nhttp://t.co/Am1qlGaYyP\n. lineSpacing is 10 for KILabel.

When you do https://github.com/Krelborn/KILabel/blob/master/KILabel/Source/KILabel.m#L550, the textBounds was incorrectly missing the last empty line, but including line spacing.

Krelborn commented 9 years ago

Looks like there's a simple fix for this which is to use usedRectForTextContainer: to calculate the bounds from the layout manager. The method currently used is giving the smallest possible bounds which excludes whitespace.

Krelborn commented 9 years ago

Fixed in the develop branch. Point your Podspec at the branch to try it out.

pod 'KILabel', :branch: 'develop'

I will do an official 1.0.1 bugfix release for this relatively soon.

d6u commented 9 years ago

This fixed the issue. Thanks! I really like your library. I tried TTTAttributedLabel before but it renders text differently when contains emoji or CJK characters. It would be really nice to add customized "links" other than just hashtag, mention, and urls. Great work!

Krelborn commented 9 years ago

No problem, thanks for the feedback.

If you want custom links have a look at the feature branch for issue #16 . It should be exactly what you want, would appreciate some feedback on that if you have any.

pod 'KILabel', :branch: 'feature/link-classifiers'