// button.titleLabel.textAlignment = Nstextalignmentleft; This sentence is invalid. Button.contenthorizontalalignment = uicontrolcontenthorizontalalignmentleft; = Uiedgeinsetsmake (000);
Here use button.titleLabel.textAlignment = Nstextalignmentleft; This line of code is not effective, it just makes the text in the label left-justified, but does not change the alignment of the label in the button.
So, first we have to use button.contenthorizontalalignment = uicontrolcontenthorizontalalignmentleft; this line of code, Change the alignment of the button's content (Control) to horizontal left-aligned, but this will stick to the left and not look good, so we can also modify the properties:
button.titleedgeinsets = uiedgeinsetsmake(0, ten, 0, 0);
This line of code allows the button's contents (controls) to be 10 pixels from the left, so it looks much better.
How to make the button text left-aligned on iOS (alignment)