How to control the padding between image and text in NSAttributedString?

Viewed 1181

I use NSTextAttachment for embedding a image in NSAttributedString . But I found the image(the PK Icon) is be so closed to the text, if I want to make some distance between them , how to achieve this.

enter image description here

NSMutableAttributedString* attri = [[NSMutableAttributedString alloc] initWithString:[NSString stringWithFormat:@" %@",item.title]];
if (item.isPK)
{
    NSTextAttachment *imageAtta = [[NSTextAttachment alloc] init];
    imageAtta.bounds = CGRectMake(0, 0, 27, 13);
    imageAtta.image = [UIImage imageNamed:@"PKIcon"];
    NSAttributedString *attach = [NSAttributedString attributedStringWithAttachment:imageAtta];
    [attri insertAttributedString:attach atIndex:0];
}

self.titleLabel.attributedText = attri;
0 Answers
Related