lexrus / LTMorphingLabel

[EXPERIMENTAL] Graceful morphing effects for UILabel written in Swift.
MIT License
8.07k stars 782 forks source link

Attributed Text Support #39

Open freshking opened 9 years ago

freshking commented 9 years ago

I believe the current version doesn't support morphing for attributed text. Will this be a feature in the near future?

lexrus commented 9 years ago

It requires tons of tweaks. I hope I have enough time to do it.

lexrus commented 9 years ago

Here is the concept.

┌─────────────────────────────────────────────────────────────┐
│        self.attributedString = ...SOME_NEW_STRING...        │
└─────────────────────────────────────────────────────────────┘
                               │                               
               ┌───────────────┘                               
               ▼                   ┌──────────────────────────┐
┌─────────────────────────────┐ ┌─▶│ enumerate each character │
│ draw the string off screen  │─┘  └──────────────────────────┘
└─────────────────────────────┘                  │             
                               ┌─────────────────┘             
                               ▼                               
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃     return ([rectOfChar], [colorOfChar], [fontOfChar])      ┃
┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
                               │                               
                               ▼                               
┌─────────────────────────────────────────────────────────────┐
│     calculate the new tuple by current morphingProgress     │
└─────────────────────────────────────────────────────────────┘
                               │                               
                               ▼                               
┌─────────────────────────────────────────────────────────────┐
│    draw each character on screen between display blinks     │
└─────────────────────────────────────────────────────────────┘
jkritikos commented 9 years ago

+100 for the effort! I tried approaching this but could not get it to work…

On Jul 23, 2015, at 4:27 PM, Lex Tang notifications@github.com wrote:

It requires tons of tweaks. I hope I have enough time to do it.

— Reply to this email directly or view it on GitHub.

LivioGama commented 8 years ago

Oh :( I needed this feature too because I use attributed string :(

sentiasa commented 8 years ago

Brilliant library!! That would be amazing if it supported Attributed String. @lexrus you wrote your last comment a year ago; is there any news for attributed string enhancement? In my case, the only reason I wanted to use attributed string is to be able to give 'character spacing'

36bydesign commented 8 years ago

+1

rakeshtookan commented 7 years ago

Any update on NSAttributedString or character spacing support?

elfanek commented 6 years ago

This is definitely more of a work around than a solution, but if you're trying to set character spacing you can play around with these whitespace characters and insert one between every character in your label when setting the text. I've found that thin space and punctuation space look nice, but you'll have to play around with a few to find one that fits your style guide best.

Not ideal, but it works ¯_(ツ)_/¯

tkirby commented 5 years ago

+1

holla-lishuangcheng commented 2 years ago

i want to