ios - Fixing NSAttributedString background color on center-justified text -


i'm running strange problem uilabel text center-justified , attributed text has background color...

on linebreaks, background color drawn label's edge first character, not behind characters. solvable problem - can make background color appear behind actual text?

actual behavior (arrows pointing places should white): enter image description here

desired behavior (from affinity designer) enter image description here


and curious, code:

- (void)viewdidload { [super viewdidload]; // additional setup after loading view, typically nib.  nsstring *texttouse = @"lorem ipsum dolor sit amet, consectetur adipiscing elit. vestibulum id malesuada diam. ut eget odio libero. sed urna elit, vestibulum et felis consequat, porta bibendum lorem";  nsdictionary *descriptionattr = @{                                   nsforegroundcolorattributename : [uicolor blackcolor],                                   nsbackgroundcolorattributename : [uicolor yellowcolor],                                   }; self.attrlabel.attributedtext = [[nsattributedstring alloc] initwithstring:texttouse attributes:descriptionattr];  } 


Comments