UILabel subclass that lets you add gradient and outline text
In this example we can see how to add the gradient to the text.
label.textGradientColors = [.blue, .green]
In this example we can see how to customize the text gradient.
label.textGradientColors = [.cyan, .blue, .purple, .systemPink]
label.textGradientStartPoint = CGPoint(x: 0, y: 0.5)
label.textGradientEndPoint = CGPoint(x: 1, y: 0.5)
In this example we can see how to add a white outline.
label.outlineColor = .white
label.outlineWidth = 7
In this more complete example, we can see how to add the gradient to the text, the outline and a shadow.
label.outlineWidth = 6
label.outlineGradientLocations = [0.3, 0.7]
label.outlineGradientColors = [.yellow, .red]
label.textGradientColors = [.orange, .yellow]
label.textGradientLocations = [0.3, 0.7]
label.shadowColor = UIColor.gray.withAlphaComponent(0.2)
label.shadowOffset = CGSize(width: 0, height: 4)
© Adriano Cosme Rezena | 2021