如何为iOS应用程序设置UILabel的左上角对齐方式? [英] How to set top-left alignment for UILabel for iOS application?
问题描述
我在我的nib文件中添加了一个标签,然后需要对该标签进行左上角对齐。因为我在运行时提供文本所以它不确定有多少行。
因此,如果文本只包含单行,则它显示为垂直居中对齐。该对齐方式与我前面的标签不匹配。
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.
例如:
这看起来很奇怪:(
有什么方法可以将标签文本设置为左上角对齐吗?
推荐答案
我将链接到这个相当广泛和高度评价的问题/答案,而不是重新解释:
Rather than re-explaining, I will link to this rather extensive & highly rated question/answer:
简短的回答是否定的,苹果并没有让这很容易,但可以通过改变框架尺寸来实现。
The short answer is no, Apple didn't make this easy, but it is possible by changing the frame size.
这篇关于如何为iOS应用程序设置UILabel的左上角对齐方式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!