The effect you want to achieve: UILabel is adaptive to the width, the text is displayed in the center, and the text has a fixed distance from the left and right sides (note: only one line of text is displayed).
The problem encountered: I wanted to be lazy at first, directly add two spaces before and after the text to be displayed, and then display the text in the center. However, the display effect of this method is: the space before the text can be displayed normally, the space after the text will be automatically removed, and the resulting text will be displayed on the right.
Note: Since this method is relatively simple, no specific code will be provided. If you have any questions or have better solutions, please comment and leave a message below.