UILabel文本之前的额外空格

问题描述 投票:0回答:1

我有一个标签,如果我添加文本标签,它在文本的开头添加了一个额外的空格,app只支持纵向方向。试过以下解决方案,但没有用。附图供参考。

我在xib中创建了这个标签,其中第2行有约束前导,尾随,底部空间到容器,高度不固定,

并设置文字

dealName.text = "Cup of Coffee with A asdf asd asdf adsf ads fad"

UILabel extra spaces before and after text ios

UIlabel shows extra space before text

UILabel有多条线

UILabel单线

ios iphone ios8 uilabel
1个回答
0
投票

尝试这可能是在字符之前有任何空格这将删除此..

NSString *trimmed = [yourstring stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];

yourlable.text = trimmed;

要么

另请参阅是否从此处设置属性段间距。

© www.soinside.com 2019 - 2024. All rights reserved.