How to Make a Secret iOS App Text Animation

前端 未结 4 996
清歌不尽
清歌不尽 2020-12-29 11:59

I\'m trying to duplicate the Secret App\'s Text Label transition. Does anyone the best way to approach it?

It looks like they have each letter start out as clear tex

4条回答
  •  南笙
    南笙 (楼主)
    2020-12-29 12:33

    Here's a possible way.

    First, let's note that a UILabel can hold and display an NSAttributedString. Using NSMutableAttributedString, you can make each letter a different color.

    So, start with two labels, one right on top of the other (i.e. in front of it, hiding it), with the same text but different letter colorings. Now fade the alpha of the top one to zero, thus gradually revealing the one behind it. Thus each letter will seem gradually to assume the color of the letter behind it.

提交回复
热议问题