weijentu / automatic-height-tagcells

This is a sample project to implement features with dynamic height of UITableViewCell based on autolayout, tags aligned automatically and clickable tags.
http://www.xcodeproj.com
MIT License
225 stars 36 forks source link

Tags in the single row example (Pinterest) are not centered #8

Closed tciuro closed 7 years ago

tciuro commented 7 years ago

Allen, this is very cool. Very nicely implemented. 👍🏻

I have one comment though: in the example you provide (see your screenshot for reference), the Pinterest row is misaligned: the tags are not centered in the cell. However, for multi-line rows, it looks fine.

weijentu commented 7 years ago

@tciuro Yes, you are right. It's misaligned for single row. After an initial investigation, I found paragraphStyle.lineSpacing = 5.0; doesn't work well at that scenario. Set it to zero can fix the issue immediately; however, I'm gonna think a little bit to see if there is any better solution once I have spare time.

tciuro commented 7 years ago

Thanks a lot Allen. I'll give it a try.

weijentu commented 7 years ago

@tciuro You are welcome. By the way, it turns out that lineSpacing is applied regardless of how many lines in UILabel, I give up explicitly setting it, instead of adjusting NSLayoutAttributeTop and NSLayoutAttributeBottom to avoid the misalignment when tags are in one row.

tciuro commented 7 years ago

Looks great. Thank you!