Mrunal Mrunal - 1 year ago 81
iOS Question

How to set top-left alignment for UILabel for iOS application?

I have added one label in my nib file, then its required to have top-left alignment for that lable. As I am providing text at runtime so its not sure that how much lines there are.
So if text contains only single line then it appears as vertical-center aligned. That alignment is not matching with my respective lable in front of it.

For example:

enter image description here

Which is looking odd :(

Is there any way where i can set label text proper to Top-Left alignment?

Answer Source

Rather than re-explaining, I will link to this rather extensive & highly rated question/answer:

Vertically align text within a UILabel

The short answer is no, Apple didn't make this easy, but it is possible by changing the frame size.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download