One way to create two labels side by side with adjustable width is to use UIStackView
with fillEqually
distribution. Here's how to do it programmatically:
main.swift990 chars31 lines
Here, we've created a horizontal stack view with two labels as arranged subviews. The fillEqually
distribution makes sure that both labels have equal width. The spacing
property adds some space between the labels. Finally, we've added constraints to position the stack view at the top-left with some padding. You can adjust the padding and other properties as needed.
gistlibby LogSnag