I calculate the size of the UILabel (only the height here) from the text of the dynamic length. And I draw the border of the label layer to render the label frame. Sometimes I see a โregistrationโ above and below the label text, but not always. I do not want to fill. I suspect it refers to an attribute string, since I never encounter such a problem in a โnormalโ string label.
I see this (note the filling in the first line):

I want it:

Relevant Code:
-(void)setupQuestionView { [self.questionView setAttributedText:[self.allContents[_itemIndex] objectForKey:@"Question"]]; // new question view height CGSize constraint = CGSizeMake(kCellWidth - kLeftMargin - kRightMargin, FLT_MAX); CGSize size = [self.questionView.text sizeWithFont:[UIFont systemFontOfSize: kFontSize] constrainedToSize:constraint lineBreakMode:NSLineBreakByWordWrapping]; [self.questionView setFrame:CGRectMake(kRightMargin, kTopMargin, kCellWidth - kRightMargin * 2, size.height)]; [self.questionView.layer setBorderWidth:1.0f]; // debug }
source share