I am not looking out for code snippet. I am just curious to know how to develop a UI component which is shown below. I have multiple thoughts on creating it, but would love to know the best approach
- Create a label and do some operations on its layer
- Set background image and add text on label
- Set image which has text on it
What will be the good approach to develop it. Any suggestions please.
You want to display a single line of text. You can use a
UILabel
for that.You have a shape you want to fill. You can use a
CAShapeLayer
for that. It's best to wrap the shape layer in aUIView
subclass so that UIKit can lay it out properly.You want to put the text over the shape, so use a parent view to combine the label and the shape as subviews.
Result: