NSAttributeString Height seems align wrong when use both image and text

爱⌒轻易说出口 提交于 2019-12-10 11:48:09

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!