1

I want to include png image in between my text of a label. how to proceed with this in objective-c.

raj
  • 63
  • 5

1 Answers1

1

This is the answer in case someone find it useful----->

 NSTextAttachment *attachment = [[NSTextAttachment alloc] init];
    attachment.image = [UIImage imageNamed:@"Attach-52.png"];

    NSAttributedString *attachmentString = [NSAttributedString attributedStringWithAttachment:attachment];

    NSMutableAttributedString *myString= [[NSMutableAttributedString alloc] initWithString:@"My label text"];
    [myString appendAttributedString:attachmentString];

    myLabel.attributedText = myString;

Likewise you can add png image through NSAttributedString.

raj
  • 63
  • 5