One way to left-align a UIButton
's title is to set the contentHorizontalAlignment
to .left
(or .leading
). But this places the title flush with the left edge of the button with no margin. A common way to add some margin is to set the contentEdgeInstets
.
But my button extends from once edge of the screen to the other, so I would like the left and right margins to honor the layoutMargins
. These margins might change as the view is resized or the device is rotated.
Is there a way to set the button's insets to observe these margins? Or should I create a button from a custom view where I can use my own label and anchor it to the layoutMarginsGuide
?