Home > front end >  How do I Fade Label out at end instead of replacing end with "..." if it's too long /
How do I Fade Label out at end instead of replacing end with "..." if it's too long /

Time:01-24

I've found a solution with GTMFadeTruncatingLabelTest from image

CodePudding user response:

I am not sure about the GTMFadeTruncatingLabelTest but I can offer an alternative solution.

Steps

  1. Check if the label's text is going to be truncated
  2. If 1 is true, Create a CAGradientLayer that goes from Opaque to Transparent
  3. Apply the gradient layer as a mask to the UILabel

Implementation

If you don't want to read the rest, just Custom UILabel with fade truncated text

Limitation

This way only supports single line UILabels

  •  Tags:  
  • Related