简体   繁体   中英

UILabel extra spaces before text

I have a label, if i add text to label it added one extra space at the beginning of the text, app supports only portrait orientation. tried following solutions but no use. attached images for reference.

I have created this label in xib with number of lines 2 with constrains leading, trailing, bottom space to container, height is not fixed,

and set text like

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 with multiple lines

屏幕截图

UILabel with single line

屏幕截图

try this may be there is an any white space before character this will remove this..

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

yourlable.text = trimmed;

OR

Also see if you set attribute paragraph spacing from here..

在此处输入图片说明

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM