问题
I have a uilabel in tableviewcell ,and the label use NSAttributeString to support both image and text. But I found when the label contains image or text only , the height of label is correct ,but when label contains image and text both ,the height seems not correct .the row height seems little more big than the actual height need
and if there is text or images only ,the height is right
and I was using my Own subclass from NSTextAttachment to construct image
and the attachment code is like this
回答1:
OK, this line of code seems work, but I still don't know why well [textAttributeString addAttribute:NSBaselineOffsetAttributeName value:[NSNumber numberWithFloat:-4] range:NSMakeRange(0, textAttributeString.length)];
来源:https://stackoverflow.com/questions/27354835/nsattributestring-height-seems-align-wrong-when-use-both-image-and-text