I saw answers to vertical resizing that includes autostart, but the UILabel that I create is only needed at runtime. (I may need from zero to many of these labels.)
Examples (ignore color)
- Short text (note the same width as the longer text):

- Longer text (note the same width as the shorter text example with more lines for add'l text):

If the text can fit on one line of fixed width, the label does not need to be resized vertically. But if there are more characters, the label must expand vertically to match these additional characters. The text should contain the stroke of the line after the line. The text should begin in the upper left corner of the label.
More specific:
let marker = GMSMarker(position: myLatLng) // see http://stackoverflow.com/a/40211383/1168364 for imageWithView marker.icon = imageWithView(label) // **how do i create this label?** marker.map = map // map is a GMSMapView
These shortcuts can be anywhere on the screen. This is for a map application where each label will be placed in a random place. The location of the labels is not related to each other.
ios uilabel swift autoresize
lf215
source share