I have a UIView
which contains two UILabel
objects, which are populated programmatically. I want the left UILabel
to be right-aligned, and the right UILabel
to be left-aligned. This is my pretty ASCII representation:
___________________
| ______ ______ |
| | ASDF| |ASDF | |
| |______| |______| |
|___________________|
I have tried all sorts of masks and alignment properties to no avail. Here is what I thought the correct solution would be, so perhaps someone can point out the flaw in my understanding.
The container UIView
needs UIViewAutoResizingFlexibleWidth
so that it can expand to fit labels with variable widths. Both the left and the right UILabel
need UIViewAutoResizingFlexibleWidth
so that they expand to fit content with variable width. The left UILabel
needs UIViewAutoresizingFlexibleRightMargin
so that the left margin remains fixed. The right UILabel
needs UIViewAutoresizingFlexibleLeftMargin
so that the right margin remains fixed.
Conceptual problem with this implementation:
- As the texts expand, they could just expand over each other as that would still fit the container
I am having the overlap problem, as well as the right margin does not seem to be fixed like it is supposed to, rather there is just a large gap on the right side.
Does anyone know what might be a solution?