I am trying to add 7 x-axis values on a graph. I am trying to do this using a horizontal stackview with 7 labels inside of it, then programmatically setting each label's (subview's) contents.
But I can't get these labels to stay in the right places. Depending on the values, some labels are sometimes wider, sometimes narrower, the spacing seems to change, etc. (It appears that setting the Distribution to "Fill Equally" spaces them evenly but their width is then too narrow showing only the decimal point and the digit immediately to its left.)
Each value (label or textfield) is a number that will have a decimal point plus two to five digits (e.g., 1.0, 3.45, 678.92).
Each subview should remain the same width regardless of the contents, and remain properly centered below its corresponding grid line, with minimal spacing between each.
For example, is there a way to ensure every label has a constant width of 45 and every space between them to a width of 2, regardless of whether the label's contents is 1.1 or 2345.9?
(And, since I'm new to Swift, is there any reason to use a label vs a textfield?)
Thank you.