ios - Horizontal spacing for NSTextAttachment -
i'm trying display image in uitextfield
using nstextattachment
, want horizontal space between image , text. however, when add nskernattributename
attribute attributed string follows, resets height of attachment same height surrounding text.
var str = nsmutableattributedstring(attributedstring: nsattributedstring(attachment: imageattachment)) str.addattribute(nskernattributename, value: 10, range: nsrange(location: 0,length: 1))
is there way add horizontal space between image , text?
the direct way in string start set few space :
nstextattachment *attachment = [[nstextattachment alloc] init]; [attachment setimage:[uiimage imagenamed:@"dest_poi_content_quotation"]]; nsstring *reviewtext = [nsstring stringwithformat:@" %@", review.text]; nsmutableattributedstring *attributedstring = [[nsmutableattributedstring alloc] initwithstring:reviewtext]; nsattributedstring *attrstringwithimage = [nsattributedstring attributedstringwithattachment:attachment]; [attributedstring insertattributedstring:attrstringwithimage atindex:0]; [self.lblcomment setattributedtext:attributedstring];
Comments
Post a Comment