I have a line that has no spaces at the end of the line, but when I convert to NSAttributedString and set to a UITextView , some spaces were noticed at the end of the UILabel .
To create an NSAttributedString I use the following code. In my code, expectedLabelSize is given a great height.
UILabel *tempLbl = [[UILabel alloc]init]; tempLbl.font = txtView.font; tempLbl.text = string; NSDictionary *dictAttributes = [NSDictionary dictionaryWithObjectsAndKeys: tempLbl.font, NSFontAttributeName, aParaStyle, NSParagraphStyleAttributeName,[UIColor darkGrayColor],NSForegroundColorAttributeName, nil]; CGSize expectedLabelSize = [string boundingRectWithSize:maximumLabelSize options:NSStringDrawingUsesLineFragmentOrigin attributes:dictAttributes context: nil].size;
ios objective-c whitespace nsattributedstring
Vvk
source share