1

In my swift app I added a UILabel that is positioned below the mapkit - both elements are in my static UITableViewCell. My point in it was that with longer text, the UILabel would expand in size.

In storyboard it looks like this:

enter image description here

and the constraints for the label look as follows:

enter image description here

This UILabel has assigned class ActiveLabel taken from here: https://github.com/optonaut/ActiveLabel.swift

Currently when there's a lot of text it looks like this:

enter image description here

and that's fine, but when there's a short text, it looks like this:

enter image description here

Is there a way of moving the single line to the top of the label, so that the text starts right below the map?

I think the problem might be somewhere in the ActiveLabel class , maybe in the drawText method, but I'm not sure, could you help me with that?

user3766930
  • 5,629
  • 10
  • 51
  • 104
  • Possible duplicate of [How to set top-left alignment for UILabel for iOS application?](http://stackoverflow.com/questions/7192088/how-to-set-top-left-alignment-for-uilabel-for-ios-application) – totiDev Jan 11 '17 at 13:32
  • Put your label to the top-left and make a dynamic height with the size of your text. – Makaille Jan 11 '17 at 13:38

1 Answers1

2

There is no way to align the text to the top on a UILabel if it has large height. You should rethink your constraints and make the height of the label the same as the text. Make the bottom space to superview >= const and remove the height constraint.

Natan
  • 1,867
  • 13
  • 24